user3390527
user3390527

Reputation:

libgdx 2D animation with TexturePacker/Atlas

I'm trying to animate a 2D image, I have each of my images cut out into appropriate sizes. However I am not sure how to use the TexturePacker and TextureAtlas to animate them. I looked at the libgdx github tutorial but it does not show how it works. I have each of my seven images in appropriate format such as (image_1,image_2,image_3...etc) as suggested on the tutorial, how do I pack these images and use them with the Atlas? Any code sample would be appreciated

Upvotes: 0

Views: 875

Answers (2)

exenza
exenza

Reputation: 1056

There is an official wiki about animation, TexturePacker+TextureAtlas.

Also, a good tutorial on animation for Libgdx

And tutorial of TexturePacker + Libgdx

Upvotes: 0

user3390527
user3390527

Reputation:

Hey I figured it out guys I'm actually just suppose to pack it with the TexturePacker tool which I had to download its a separate .jar file from here and then execute this lines of code

TextureAtlas atlas;
public Animation<TextureRegion> runningAnimation;

atlas = new TextureAtlas(Gdx.files.internal("directory/pack.atlas"));
runningAnimation = new Animation<TextureRegion>(0.033f,atlas.findRegions("running"), PlayMode.LOOP);

Upvotes: 2

Related Questions