57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <memory> // for shared_ptr
|
|
#include "animated_sprite.h" // for SpriteAnimated
|
|
class Texture;
|
|
|
|
// Clase SpriteSmart
|
|
class SmartSprite : public AnimatedSprite
|
|
{
|
|
private:
|
|
// Variables
|
|
bool on_destination_ = false; // Indica si está en el destino
|
|
int dest_x_ = 0; // Posicion de destino en el eje X
|
|
int dest_y_ = 0; // Posicion de destino en el eje Y
|
|
int finished_counter_ = 0; // Contador para deshabilitarlo
|
|
bool finished_ = false; // Indica si ya ha terminado
|
|
bool enabled_ = false; // Indica si el objeto está habilitado
|
|
|
|
// Comprueba si ha terminado
|
|
void checkFinished();
|
|
|
|
// Comprueba el movimiento
|
|
void checkMove();
|
|
|
|
public:
|
|
// Constructor
|
|
explicit SmartSprite(std::shared_ptr<Texture> texture);
|
|
|
|
// Destructor
|
|
~SmartSprite() = default;
|
|
|
|
// Actualiza la posición y comprueba si ha llegado a su destino
|
|
void update() override;
|
|
|
|
// Establece el valor de la variable
|
|
void setFinishedCounter(int value);
|
|
|
|
// Establece el valor de la variable
|
|
void setDestX(int x);
|
|
|
|
// Establece el valor de la variable
|
|
void setDestY(int y);
|
|
|
|
// Obtiene el valor de la variable
|
|
int getDestX() const;
|
|
|
|
// Obtiene el valor de la variable
|
|
int getDestY() const;
|
|
|
|
// Obtiene el valor de la variable
|
|
bool isOnDestination() const;
|
|
|
|
// Obtiene el valor de la variable
|
|
bool hasFinished() const;
|
|
|
|
void setEnabled(bool value);
|
|
}; |