Actualizado animatedsprite.cpp
This commit is contained in:
@@ -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
|
// Establece el frame actual de la animación
|
||||||
void AnimatedSprite::setCurrentFrame(int num)
|
void AnimatedSprite::setCurrentFrame(int num)
|
||||||
{
|
{
|
||||||
@@ -304,7 +310,7 @@ bool AnimatedSprite::loadFromFile(std::string filePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setPos({0, 0, frameWidth, frameHeight});
|
setRect({0, 0, frameWidth, frameHeight});
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -442,7 +448,7 @@ bool AnimatedSprite::loadFromVector(std::vector<std::string> *source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setPos({0, 0, frameWidth, frameHeight});
|
setRect({0, 0, frameWidth, frameHeight});
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ private:
|
|||||||
int currentFrame; // Frame actual
|
int currentFrame; // Frame actual
|
||||||
int counter; // Contador para las animaciones
|
int counter; // Contador para las animaciones
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Variables
|
||||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||||
int currentAnimation; // Animacion activa
|
int currentAnimation; // Animacion activa
|
||||||
|
|
||||||
@@ -38,6 +40,9 @@ public:
|
|||||||
// Calcula el frame correspondiente a la animación actual
|
// Calcula el frame correspondiente a la animación actual
|
||||||
void animate();
|
void animate();
|
||||||
|
|
||||||
|
// Obtiene el numero de frames de la animación actual
|
||||||
|
int getNumFrames();
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
// Establece el frame actual de la animación
|
||||||
void setCurrentFrame(int num);
|
void setCurrentFrame(int num);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user