I'm trying now to use my animation sheet in the player class, but I'm having some doubts for my situation. I was following the documentation (https://github.com/libgdx/libgdx/wiki/2D-Animation) where it talks about 2d animation, but it just show a single type of animation, in that case, a walk animation. My context is different, I have 3 types of animation: idle, running and climbing. I wonder if it's possible hold all types of animation in a unique Animation object or I must create 3 objects for each? I also trie to find something equal on stackoverflow and google, but I found nothing.
This is what I did to my private method loadAnimations():
private void loadAnimations() {
// Get the player animations sheet
Texture playerSheet = Assets.manager.get(Assets.playersheet);
// List of texture regions that hold the animations
TextureRegion[][] tmp = TextureRegion.split(playerSheet, playerSheet.getWidth() / PLAYER_FRAME_COLS, playerSheet.getHeight() / PLAYER_FRAME_ROWS);
// Put all textures from texture region to 1-d texture region
int index = 0;
TextureRegion[] walkFrames = new TextureRegion[PLAYER_FRAME_COLS * PLAYER_FRAME_ROWS];
for (int i = 0; i < PLAYER_FRAME_ROWS; i++) {
for (int j = 0; j < PLAYER_FRAME_COLS; j++) {
walkFrames[index++] = tmp[i][j];
}
}
this.runAnimation = new Animation(FRAMES_DURTION, walkFrames);
}
And this is the Player proprietes:
private Animation idleAnimation, runAnimation, climbAnimation;
private TextureRegion currentFrame;
What do to in this case? Thank you.