Game Development Reference
In-Depth Information
The mountains object
The mountains game object consists of three mountains that each have their own
layer. A tinting color and positional offset can be specified for each layer. A single
mountain consists of a left and a right image. The ends of both image parts have
been carefully crafted so that they can be seamlessly tiled. The following screenshot
illustrates this:
The white color for the mountain images has been chosen on purpose to allow tinting.
Create a new file for the Mountains class and add the following code:
package com.packtpub.libgdx.canyonbunny.game.objects;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.MathUtils;
import com.packtpub.libgdx.canyonbunny.game.Assets;
public class Mountains extends AbstractGameObject {
private TextureRegion regMountainLeft;
private TextureRegion regMountainRight;
private int length;
public Mountains (int length) {
this.length = length;
init();
}
private void init () {
dimension.set(10, 2);
regMountainLeft =
Assets.instance.levelDecoration.mountainLeft;
regMountainRight =
Assets.instance.levelDecoration.mountainRight;
// shift mountain and extend length
 
Search WWH ::




Custom Search