v1.4
This commit is contained in:
@@ -5,9 +5,26 @@
|
||||
#ifndef ANIMATEDSPRITE_H
|
||||
#define ANIMATEDSPRITE_H
|
||||
|
||||
#define MAX_FRAMES 30
|
||||
#define MAX_ANIMATIONS 20
|
||||
|
||||
// Clase AnimatedSprite
|
||||
class AnimatedSprite : public MovingSprite
|
||||
{
|
||||
private:
|
||||
struct sAnimation
|
||||
{
|
||||
SDL_Rect frames[MAX_FRAMES]; // Cada uno de los frames que componen la animación
|
||||
Uint8 numFrames; // Numero de frames que componen la animación
|
||||
Uint8 speed; // Velocidad de la animación
|
||||
bool loop; // Indica si la animación se reproduce en bucle
|
||||
bool completed; // Indica si ha finalizado la animación
|
||||
};
|
||||
sAnimation mAnimation[MAX_ANIMATIONS]; // Vector con las diferentes animaciones
|
||||
|
||||
Uint8 mCurrentFrame; // Frame actual
|
||||
Uint16 mAnimationCounter; // Contador para las animaciones
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
AnimatedSprite();
|
||||
@@ -39,26 +56,14 @@ public:
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void setAnimationLoop(Uint8 index, bool loop);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setCompleted(Uint8 index, bool value);
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool isCompleted(Uint8 index);
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect getAnimationClip(Uint8 index_animation, Uint8 index_frame);
|
||||
|
||||
private:
|
||||
struct sAnimation
|
||||
{
|
||||
SDL_Rect frames[20]; // Hasta 20 frames
|
||||
Uint8 numFrames;
|
||||
Uint8 speed;
|
||||
bool loop;
|
||||
};
|
||||
|
||||
// Vector con las diferentes animaciones y los diferentes frames de cada animación
|
||||
sAnimation mAnimation[20]; // Hasta 20 animaciones
|
||||
|
||||
// Frame actual
|
||||
Uint8 mCurrentFrame;
|
||||
|
||||
// Contador para las animaciones
|
||||
Uint16 mAnimationCounter;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user