Game Development Reference
In-Depth Information
Add the following lines to the inner class AssetLevelDecoration of the
Assets class:
public final AtlasRegion carrot;
public final AtlasRegion goal;
Next, make the following changes to the same (inner) class so that the new images
will become available for later use:
public AssetLevelDecoration (TextureAtlas atlas) {
waterOverlay = atlas.findRegion("water_overlay");
carrot = atlas.findRegion("carrot");
goal = atlas.findRegion("goal");
}
Adding the carrot game object
The carrot is just a normal game object like any other, as shown here, that we have
created for Canyon Bunny so far:
Create a new file for the Carrot 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.packtpub.libgdx.canyonbunny.game.Assets;
public class Carrot extends AbstractGameObject {
private TextureRegion regCarrot;
public Carrot () {
init();
}
private void init () {
 
Search WWH ::




Custom Search