57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "animated_sprite.h" // for AnimatedSprite
|
|
#include "texture.h"
|
|
#include <memory>
|
|
|
|
// Clase SmartSprite
|
|
class SmartSprite : public AnimatedSprite
|
|
{
|
|
private:
|
|
// Variables
|
|
bool onDestination_; // Indica si está en el destino
|
|
int destX_; // Posicion de destino en el eje X
|
|
int destY_; // Posicion de destino en el eje Y
|
|
int finishedCounter_; // Contador para deshabilitarlo
|
|
bool finished_; // Indica si ya ha terminado
|
|
|
|
// Comprueba el movimiento
|
|
void checkMove();
|
|
|
|
// Comprueba si ha terminado
|
|
void checkFinished();
|
|
|
|
public:
|
|
// Constructor
|
|
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();
|
|
|
|
// 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;
|
|
}; |