cleanup time-based: elimina base classes frame-based (MovingSprite/SmartSprite/AnimatedSprite/Writer/Fade), MovingSprite::update(dt_s) integra rotacio
This commit is contained in:
@@ -211,39 +211,7 @@ auto AnimatedSprite::getIndex(const std::string &name) -> int {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Calcula el frame correspondiente a la animación
|
||||
void AnimatedSprite::animate() {
|
||||
if (!enabled_ || animation_[current_animation_].speed == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calcula el frame actual a partir del contador
|
||||
animation_[current_animation_].current_frame = animation_[current_animation_].counter / animation_[current_animation_].speed;
|
||||
|
||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||
// en función de la variable loop y coloca el nuevo frame
|
||||
if (animation_[current_animation_].current_frame >= (int)animation_[current_animation_].frames.size()) {
|
||||
if (animation_[current_animation_].loop == -1) { // Si no hay loop, deja el último frame
|
||||
animation_[current_animation_].current_frame = animation_[current_animation_].frames.size();
|
||||
animation_[current_animation_].completed = true;
|
||||
} else { // Si hay loop, vuelve al frame indicado
|
||||
animation_[current_animation_].counter = 0;
|
||||
animation_[current_animation_].current_frame = animation_[current_animation_].loop;
|
||||
}
|
||||
}
|
||||
// En caso contrario
|
||||
else {
|
||||
// Escoge el frame correspondiente de la animación
|
||||
setSpriteClip(animation_[current_animation_].frames[animation_[current_animation_].current_frame]);
|
||||
|
||||
// Incrementa el contador de la animacion
|
||||
animation_[current_animation_].counter++;
|
||||
}
|
||||
}
|
||||
|
||||
// Time-based: avança l'acumulador i calcula el frame actual a partir de
|
||||
// `step_duration_s`. La lògica de loop/completed és la mateixa que la
|
||||
// variant frame-based.
|
||||
// Avança l'acumulador i calcula el frame actual a partir de `step_duration_s`.
|
||||
void AnimatedSprite::animate(float dt_s) {
|
||||
Animation &anim = animation_[current_animation_];
|
||||
if (!enabled_ || anim.step_duration_s <= 0.0F) {
|
||||
@@ -376,13 +344,7 @@ void AnimatedSprite::setCurrentAnimation(int index) {
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void AnimatedSprite::update() {
|
||||
animate();
|
||||
MovingSprite::update();
|
||||
}
|
||||
|
||||
// Time-based: animate(dt) + move(dt)
|
||||
// animate(dt) + MovingSprite::update(dt) (move + rotació)
|
||||
void AnimatedSprite::update(float dt_s) {
|
||||
animate(dt_s);
|
||||
MovingSprite::update(dt_s);
|
||||
|
||||
Reference in New Issue
Block a user