diff --git a/source/moving_sprite.cpp b/source/moving_sprite.cpp index 49d4c8c..73f1c0f 100644 --- a/source/moving_sprite.cpp +++ b/source/moving_sprite.cpp @@ -90,6 +90,19 @@ void MovingSprite::setRotate(bool enable) { rotate_.enabled = enable; } +// Habilita la rotación y establece el centro en el centro del sprite +void MovingSprite::startRotate() { + rotate_.enabled = true; + rotate_.center.x = pos_.w / 2.0F; + rotate_.center.y = pos_.h / 2.0F; +} + +// Detiene la rotación y resetea el ángulo a cero +void MovingSprite::stopRotate() { + rotate_.enabled = false; + rotate_.angle = 0.0; +} + // Establece la posición y_ el tamaño del objeto void MovingSprite::setPos(SDL_FRect rect) { x_ = rect.x; diff --git a/source/moving_sprite.h b/source/moving_sprite.h index 5b7a9d3..9f7496f 100644 --- a/source/moving_sprite.h +++ b/source/moving_sprite.h @@ -46,6 +46,8 @@ class MovingSprite : public Sprite { void setAngle(double value) { rotate_.angle = value; } // Establece el ángulo void setRotatingCenter(SDL_FPoint point) { rotate_.center = point; } // Establece el centro de rotación void setRotate(bool enable); // Activa o desactiva el efecto de rotación + void startRotate(); // Habilita la rotación con centro automático + void stopRotate(); // Detiene la rotación y resetea ángulo void setRotateAmount(double value) { rotate_.amount = value; } // Establece la cantidad de rotación void switchRotate() { rotate_.amount *= -1; } // Cambia el sentido de la rotación void setFlip(SDL_FlipMode flip) { flip_ = flip; } // Establece el flip