Continue arreglant cosetes amb cppcheck
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#include "animated_sprite.h"
|
||||
#include <algorithm> // for copy
|
||||
#include <fstream> // for basic_ostream, operator<<, basic_istream, basic...
|
||||
#include <iostream> // for cout
|
||||
#include <iterator> // for back_insert_iterator, back_inserter
|
||||
#include <sstream> // for basic_stringstream
|
||||
#include "texture.h" // for Texture
|
||||
#include <algorithm> // para copy
|
||||
#include <fstream> // para basic_ostream, operator<<, basic_istream, basic...
|
||||
#include <iostream> // para cout
|
||||
#include <iterator> // para back_insert_iterator, back_inserter
|
||||
#include <sstream> // para basic_stringstream
|
||||
#include "texture.h" // para Texture
|
||||
#include "utils.h"
|
||||
|
||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||
@@ -106,65 +106,18 @@ void AnimatedSprite::animate()
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el número de frames de la animación actual
|
||||
int AnimatedSprite::getNumFrames()
|
||||
{
|
||||
return (int)animations_[current_animation_].frames.size();
|
||||
}
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void AnimatedSprite::setCurrentFrame(int num)
|
||||
{
|
||||
// Descarta valores fuera de rango
|
||||
if (num >= (int)animations_[current_animation_].frames.size())
|
||||
{
|
||||
num = 0;
|
||||
}
|
||||
|
||||
// Cambia el valor de la variable
|
||||
animations_[current_animation_].current_frame = num;
|
||||
animations_[current_animation_].counter = 0;
|
||||
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||
}
|
||||
|
||||
// Establece el valor del contador
|
||||
void AnimatedSprite::setAnimationCounter(const std::string &name, int num)
|
||||
{
|
||||
animations_[getIndex(name)].counter = num;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(const std::string &name, int speed)
|
||||
{
|
||||
animations_[getIndex(name)].counter = speed;
|
||||
}
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||
{
|
||||
animations_[index].counter = speed;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(const std::string &name, int loop)
|
||||
{
|
||||
animations_[getIndex(name)].loop = loop;
|
||||
}
|
||||
|
||||
// Establece si la animación se reproduce en bucle
|
||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||
{
|
||||
animations_[index].loop = loop;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(const std::string &name, bool value)
|
||||
{
|
||||
animations_[getIndex(name)].completed = value;
|
||||
}
|
||||
|
||||
// OLD - Establece el valor de la variable
|
||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||
{
|
||||
@@ -222,21 +175,6 @@ void AnimatedSprite::update()
|
||||
MovingSprite::update();
|
||||
}
|
||||
|
||||
// Establece el rectangulo para un frame de una animación
|
||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||
{
|
||||
animations_[index_animation].frames.push_back({x, y, w, h});
|
||||
}
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void AnimatedSprite::setAnimationCounter(int value)
|
||||
{
|
||||
for (auto &a : animations_)
|
||||
{
|
||||
a.counter = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Reinicia la animación
|
||||
void AnimatedSprite::resetAnimation()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user