Arreglades les herencies de Sprite
Abans de llevar mil coses que sobren i replantejar-se estes 4 classes
This commit is contained in:
@@ -4,20 +4,18 @@ class Texture;
|
||||
|
||||
// Constructor
|
||||
SmartSprite::SmartSprite(std::shared_ptr<Texture> texture)
|
||||
: AnimatedSprite(texture)
|
||||
{
|
||||
// Copia punteros
|
||||
setTexture(texture);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
// Inicializa el objeto
|
||||
void SmartSprite::init()
|
||||
{
|
||||
finishedCounter_ = 0;
|
||||
onDestination_ = false;
|
||||
destX_ = 0;
|
||||
destY_ = 0;
|
||||
finished_counter_ = 0;
|
||||
on_destination_ = false;
|
||||
dest_x_ = 0;
|
||||
dest_y_ = 0;
|
||||
finished_ = false;
|
||||
enabled_ = false;
|
||||
}
|
||||
@@ -36,31 +34,31 @@ void SmartSprite::update()
|
||||
// Establece el valor de la variable
|
||||
void SmartSprite::setFinishedCounter(int value)
|
||||
{
|
||||
finishedCounter_ = value;
|
||||
finished_counter_ = value;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void SmartSprite::setDestX(int x)
|
||||
{
|
||||
destX_ = x;
|
||||
dest_x_ = x;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void SmartSprite::setDestY(int y)
|
||||
{
|
||||
destY_ = y;
|
||||
dest_y_ = y;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int SmartSprite::getDestX() const
|
||||
{
|
||||
return destX_;
|
||||
return dest_x_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int SmartSprite::getDestY() const
|
||||
{
|
||||
return destY_;
|
||||
return dest_y_;
|
||||
}
|
||||
|
||||
// Comprueba el movimiento
|
||||
@@ -70,10 +68,10 @@ void SmartSprite::checkMove()
|
||||
if (getAccelX() > 0 || getVelX() > 0)
|
||||
{
|
||||
// Comprueba si ha llegado al destino
|
||||
if (getPosX() > destX_)
|
||||
if (getPosX() > dest_x_)
|
||||
{
|
||||
// Lo coloca en posición
|
||||
setPosX(destX_);
|
||||
setPosX(dest_x_);
|
||||
|
||||
// Lo detiene
|
||||
setVelX(0.0f);
|
||||
@@ -84,10 +82,10 @@ void SmartSprite::checkMove()
|
||||
else if (getAccelX() < 0 || getVelX() < 0)
|
||||
{
|
||||
// Comprueba si ha llegado al destino
|
||||
if (getPosX() < destX_)
|
||||
if (getPosX() < dest_x_)
|
||||
{
|
||||
// Lo coloca en posición
|
||||
setPosX(destX_);
|
||||
setPosX(dest_x_);
|
||||
|
||||
// Lo detiene
|
||||
setVelX(0.0f);
|
||||
@@ -99,10 +97,10 @@ void SmartSprite::checkMove()
|
||||
if (getAccelY() > 0 || getVelY() > 0)
|
||||
{
|
||||
// Comprueba si ha llegado al destino
|
||||
if (getPosY() > destY_)
|
||||
if (getPosY() > dest_y_)
|
||||
{
|
||||
// Lo coloca en posición
|
||||
setPosY(destY_);
|
||||
setPosY(dest_y_);
|
||||
|
||||
// Lo detiene
|
||||
setVelY(0.0f);
|
||||
@@ -113,10 +111,10 @@ void SmartSprite::checkMove()
|
||||
else if (getAccelY() < 0 || getVelY() < 0)
|
||||
{
|
||||
// Comprueba si ha llegado al destino
|
||||
if (getPosY() < destY_)
|
||||
if (getPosY() < dest_y_)
|
||||
{
|
||||
// Lo coloca en posición
|
||||
setPosY(destY_);
|
||||
setPosY(dest_y_);
|
||||
|
||||
// Lo detiene
|
||||
setVelY(0.0f);
|
||||
@@ -129,17 +127,17 @@ void SmartSprite::checkMove()
|
||||
void SmartSprite::checkFinished()
|
||||
{
|
||||
// Comprueba si ha llegado a su destino
|
||||
onDestination_ = (getPosX() == destX_ && getPosY() == destY_) ? true : false;
|
||||
on_destination_ = (getPosX() == dest_x_ && getPosY() == dest_y_) ? true : false;
|
||||
|
||||
if (onDestination_)
|
||||
if (on_destination_)
|
||||
{
|
||||
if (finishedCounter_ == 0)
|
||||
if (finished_counter_ == 0)
|
||||
{
|
||||
finished_ = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
--finishedCounter_;
|
||||
--finished_counter_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,11 +145,16 @@ void SmartSprite::checkFinished()
|
||||
// Obtiene el valor de la variable
|
||||
bool SmartSprite::isOnDestination() const
|
||||
{
|
||||
return onDestination_;
|
||||
return on_destination_;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool SmartSprite::hasFinished() const
|
||||
{
|
||||
return finished_;
|
||||
}
|
||||
|
||||
void SmartSprite::setEnabled(bool value)
|
||||
{
|
||||
enabled_ = value;
|
||||
}
|
||||
Reference in New Issue
Block a user