Created
October 16, 2017 09:47
-
-
Save sparkica/6571e4d60071e1eb0004de3d972fb87b to your computer and use it in GitHub Desktop.
Beginning game development with LibGDX - creating animations - first approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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