revisat motor de animacions
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <unordered_map> // Para unordered_map
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
@@ -27,9 +28,6 @@ class AnimatedSprite : public MovingSprite {
|
||||
float accumulated_time{0.0F}; // Tiempo acumulado para las animaciones (time-based)
|
||||
};
|
||||
|
||||
// Métodos estáticos
|
||||
static auto loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData>; // Carga las animaciones desde fichero YAML
|
||||
|
||||
// Constructores
|
||||
explicit AnimatedSprite(const AnimationResource& cached_data); // Constructor con datos pre-cargados del cache
|
||||
|
||||
@@ -39,7 +37,6 @@ class AnimatedSprite : public MovingSprite {
|
||||
|
||||
// Consultas de estado
|
||||
auto animationIsCompleted() -> bool; // Comprueba si ha terminado la animación
|
||||
auto getIndex(const std::string& name) -> int; // Obtiene el índice de la animación por nombre
|
||||
auto getCurrentAnimationSize() -> int { return static_cast<int>(animations_[current_animation_].frames.size()); } // Número de frames de la animación actual
|
||||
|
||||
// Modificadores de animación
|
||||
@@ -54,7 +51,10 @@ class AnimatedSprite : public MovingSprite {
|
||||
AnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
|
||||
private:
|
||||
void buildNameIndex(); // Construye el mapa nombre→índice
|
||||
|
||||
// Variables miembro
|
||||
std::vector<AnimationData> animations_; // Vector con las diferentes animaciones
|
||||
int current_animation_{0}; // Animación activa
|
||||
std::vector<AnimationData> animations_; // Vector con las diferentes animaciones
|
||||
std::unordered_map<std::string, int> animation_index_; // Mapa nombre→índice para búsqueda O(1)
|
||||
int current_animation_{0}; // Animación activa
|
||||
};
|
||||
Reference in New Issue
Block a user