Trabajando en la cache de animaciones

This commit is contained in:
2022-10-27 18:13:22 +02:00
parent 6186d1fac1
commit 35b4d19188
6 changed files with 110 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
#include "animatedsprite.h"
// Carga la animación desde un fichero
animatedSprite_t loadFromFile(Texture *texture, std::string filePath)
animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath)
{
// Inicializa variables
animatedSprite_t as;
@@ -80,7 +80,6 @@ animatedSprite_t loadFromFile(Texture *texture, std::string filePath)
// Añade la animación al vector de animaciones
as.animations.push_back(buffer);
// animation.push_back(buffer);
}
// En caso contrario se parsea el fichero para buscar las variables y los valores
@@ -173,19 +172,19 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::st
}
// Constructor
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t as)
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
{
// Copia los punteros
setTexture(as.texture);
setTexture(animation->texture);
setRenderer(renderer);
// Inicializa variables
currentAnimation = 0;
// Copia los datos de las animaciones
for (auto animation : as.animations)
for (auto a : animation->animations)
{
this->animation.push_back(animation);
this->animation.push_back(a);
}
}