I'm learning how to make games using LibGDX and I'm trying to make a small platform game (using Eclipse). I made 4 images on the main character running to make an animation when he moves. However, I can't find anything online to show me how to make an animation without using a SpriteSheet. How do you make an animation using 4 different images ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
First of all: You should not use different images. Maybe for your player it does not matter much (because there is only one) but in general you should always use sprite sheets, a.k.a.
TextureAtlas
.However, it is possible without it by using different textures.
You should use a TexturePacker with TextureAtlas. Adding every texture by hand is not the right way.
The texture packer packs your several images into one image. Use names like this: img_01.png, img_02.png etc, and you extract them all in one line of code in an Array.
I will post code examples in a few hours when i get home.
I actually had an separate class for dealing with loading of assets:
And the code that loads animation :
My original animation images were run_001.png, run_002.png, ...
Because your file names have a format name_0001.png the Texture packer puts animation keyframes in one file and they all have one name "name" and a additional parameter "index" that is the number in your file name, for example 001, 002, 003, etc.
And
Assets.atlas.findRegions("run")
returns an Array with the keyframes.