sparkica
10/16/2017 - 9:47 AM

Beginning game development with LibGDX - creating animations - first approach

Beginning game development with LibGDX - creating animations - first approach

// Initialize object
float animationDuration = 0;
TextureAtlas atlas = new TextureAtlas("coin-animation.atlas");
Animation animation = new Animation(23 / 1000f, atlas.getRegions());

// Update object
animationDuration += delta;

// Render object
TextureRegion reg = (TextureRegion)mFlyAnimation.getKeyFrame(animationDuration, true); // loop is set on true
batch.draw(reg, position.x, position.y, dimension.x, dimension.y);

// Destroy object
atlas.dispose();