* Crea las animaciones del personaje
*/
private void createAnimations() {
// Carga la animación de un spritesheet (todos los frames están en un mismo fichero)
Texture spriteSheet = ResourceManager.assets.get("player/player_right_animation.png", Texture.class);
TextureRegion[][] frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / FRAMES, spriteSheet.getHeight());
TextureRegion[] rightFrames = new TextureRegion[FRAMES];
for (int i = 0; i < FRAMES; i++) {
rightFrames[i] = frames[0][i];
}
rightAnimation = new Animation(0.15f, rightFrames);
spriteSheet = ResourceManager.assets.get("player/player_left_animation.png", Texture.class);
frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / FRAMES, spriteSheet.getHeight());
rightFrames = new TextureRegion[FRAMES];
for (int i = 0; i < FRAMES; i++) {
rightFrames[i] = frames[0][i];
}
leftAnimation = new Animation(0.15f, rightFrames);
spriteSheet = ResourceManager.assets.get("player/player_up_animation.png", Texture.class);
frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / FRAMES, spriteSheet.getHeight());
rightFrames = new TextureRegion[FRAMES];
for (int i = 0; i < FRAMES; i++) {
rightFrames[i] = frames[0][i];
}
upAnimation = new Animation(0.15f, rightFrames);
spriteSheet = ResourceManager.assets.get("player/player_down_animation.png", Texture.class);
frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / FRAMES, spriteSheet.getHeight());
rightFrames = new TextureRegion[FRAMES];
for (int i = 0; i < FRAMES; i++) {
rightFrames[i] = frames[0][i];
}
downAnimation = new Animation(0.15f, rightFrames);
spriteSheet = ResourceManager.assets.get("player/player_explosion_animation.png", Texture.class);
frames = TextureRegion.split(spriteSheet, spriteSheet.getWidth() / (FRAMES * 2), spriteSheet.getHeight());
rightFrames = new TextureRegion[FRAMES * 2];
for (int i = 0; i < FRAMES * 2; i++) {
rightFrames[i] = frames[0][i];
}
explosionAnimation = new Animation(0.2f, rightFrames);