moving_sprite.cpp: afegit umbral a stopRotate()
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "moving_sprite.h"
|
#include "moving_sprite.h"
|
||||||
|
|
||||||
|
#include <cmath> // Para std::abs
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
@@ -98,10 +99,12 @@ void MovingSprite::startRotate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detiene la rotación y resetea el ángulo a cero
|
// Detiene la rotación y resetea el ángulo a cero
|
||||||
void MovingSprite::stopRotate() {
|
void MovingSprite::stopRotate(float threshold) {
|
||||||
|
if (threshold == 0.0F || std::abs(rotate_.amount) <= threshold) {
|
||||||
rotate_.enabled = false;
|
rotate_.enabled = false;
|
||||||
rotate_.angle = 0.0;
|
rotate_.angle = 0.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Establece la posición y_ el tamaño del objeto
|
// Establece la posición y_ el tamaño del objeto
|
||||||
void MovingSprite::setPos(SDL_FRect rect) {
|
void MovingSprite::setPos(SDL_FRect rect) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class MovingSprite : public Sprite {
|
|||||||
void setRotatingCenter(SDL_FPoint point) { rotate_.center = point; } // Establece el centro de rotación
|
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 setRotate(bool enable); // Activa o desactiva el efecto de rotación
|
||||||
void startRotate(); // Habilita la rotación con centro automático
|
void startRotate(); // Habilita la rotación con centro automático
|
||||||
void stopRotate(); // Detiene la rotación y resetea ángulo
|
void stopRotate(float threshold = 0.0F); // Detiene la rotación y resetea ángulo
|
||||||
void setRotateAmount(double value) { rotate_.amount = value; } // Establece la velocidad de rotación
|
void setRotateAmount(double value) { rotate_.amount = value; } // Establece la velocidad de rotación
|
||||||
void scaleRotateAmount(float value) { rotate_.amount *= value; } // Modifica la velocidad de rotacion
|
void scaleRotateAmount(float value) { rotate_.amount *= value; } // Modifica la velocidad de rotacion
|
||||||
void switchRotate() { rotate_.amount *= -1; } // Cambia el sentido de la rotación
|
void switchRotate() { rotate_.amount *= -1; } // Cambia el sentido de la rotación
|
||||||
|
|||||||
Reference in New Issue
Block a user