Skip to content

Instantly share code, notes, and snippets.

@sparkica
Created October 16, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparkica/6571e4d60071e1eb0004de3d972fb87b to your computer and use it in GitHub Desktop.
Save sparkica/6571e4d60071e1eb0004de3d972fb87b to your computer and use it in GitHub Desktop.
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment