Game Development Reference
In-Depth Information
Now, let's put all these animations in our Assets class for later use. Add the
following import lines to the Assets class:
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.utils.Array;
Then, make the following changes to the same class:
public class AssetGoldCoin {
public final AtlasRegion goldCoin;
public final Animation animGoldCoin;
public AssetGoldCoin (TextureAtlas atlas) {
goldCoin = atlas.findRegion("item_gold_coin");
// Animation: Gold Coin
Array<AtlasRegion> regions =
atlas.findRegions("anim_gold_coin");
AtlasRegion region = regions.first();
for (int i = 0; i < 10; i++)
regions.insert(0, region);
animGoldCoin = new Animation(1.0f / 20.0f, regions,
Animation.PlayMode.LOOP_PINGPONG);
}
}
public class AssetBunny {
public final AtlasRegion head;
public final Animation animNormal;
public final Animation animCopterTransform;
public final Animation animCopterTransformBack;
public final Animation animCopterRotate;
public AssetBunny (TextureAtlas atlas) {
head = atlas.findRegion("bunny_head");
Array<AtlasRegion> regions = null;
AtlasRegion region = null;
// Animation: Bunny Normal
regions = atlas.findRegions("anim_bunny_normal");
animNormal = new Animation(1.0f / 10.0f, regions,
Animation.PlayMode.LOOP_PINGPONG);
// Animation: Bunny Copter - knot ears
 
Search WWH ::




Custom Search