60 lines
1.3 KiB
C++
60 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_; // Indica si está en el destino
|
|
int dest_x_; // Posicion de destino en el eje X
|
|
int dest_y_; // Posicion de destino en el eje Y
|
|
int finished_counter_; // Contador para deshabilitarlo
|
|
bool finished_; // Indica si ya ha terminado
|
|
bool enabled_; // 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;
|
|
|
|
// Inicializa el objeto
|
|
void init();
|
|
|
|
// 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);
|
|
}; |