From 7ab81eaf29dbdf3dec8fbf0953cec16a48bebe0a Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 20 Oct 2022 09:18:18 +0200 Subject: [PATCH] Actualizado animatedsprite.cpp --- source/common/animatedsprite.cpp | 10 ++++++++-- source/common/animatedsprite.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/common/animatedsprite.cpp b/source/common/animatedsprite.cpp index 449ebd1..a218957 100644 --- a/source/common/animatedsprite.cpp +++ b/source/common/animatedsprite.cpp @@ -88,6 +88,12 @@ void AnimatedSprite::animate() } } +// Obtiene el numero de frames de la animación actual +int AnimatedSprite::getNumFrames() +{ + return (int)animation.at(currentAnimation).frames.size(); +} + // Establece el frame actual de la animación void AnimatedSprite::setCurrentFrame(int num) { @@ -304,7 +310,7 @@ bool AnimatedSprite::loadFromFile(std::string filePath) } // Pone un valor por defecto - setPos({0, 0, frameWidth, frameHeight}); + setRect({0, 0, frameWidth, frameHeight}); return success; } @@ -442,7 +448,7 @@ bool AnimatedSprite::loadFromVector(std::vector *source) } // Pone un valor por defecto - setPos({0, 0, frameWidth, frameHeight}); + setRect({0, 0, frameWidth, frameHeight}); return success; } diff --git a/source/common/animatedsprite.h b/source/common/animatedsprite.h index 2e93b7e..c9bab9d 100644 --- a/source/common/animatedsprite.h +++ b/source/common/animatedsprite.h @@ -25,6 +25,8 @@ private: int currentFrame; // Frame actual int counter; // Contador para las animaciones }; + + // Variables std::vector animation; // Vector con las diferentes animaciones int currentAnimation; // Animacion activa @@ -38,6 +40,9 @@ public: // Calcula el frame correspondiente a la animación actual void animate(); + // Obtiene el numero de frames de la animación actual + int getNumFrames(); + // Establece el frame actual de la animación void setCurrentFrame(int num);