Game Development Reference
In-Depth Information
private TextureRegion regWaterOverlay;
private float length;
public WaterOverlay (float length) {
this.length = length;
init();
}
private void init () {
dimension.set(length * 10, 3);
regWaterOverlay =
Assets.instance.levelDecoration.waterOverlay;
origin.x = -dimension.x / 2;
}
@Override
public void render (SpriteBatch batch) {
TextureRegion reg = null;
reg = regWaterOverlay;
batch.draw(reg.getTexture(), position.x + origin.x, position.y
+ origin.y, origin.x, origin.y, dimension.x, dimension.y, scale.x,
scale.y, rotation, reg.getRegionX(), reg.getRegionY(),
reg.getRegionWidth(), reg.getRegionHeight(), false, false);
}
}
The WaterOverlay class is constructed similar to the previous game objects.
The clouds object
The clouds game object consists of a number of clouds. A cloud will use one of the
three available cloud images from the texture atlas. The number of clouds depends
on the given length that is divided by a constant factor to determine the final
distribution of the clouds. The following screenshot illustrates this:
 
Search WWH ::




Custom Search