Resueltos los dos últimos problemas

This commit is contained in:
2022-10-03 17:14:33 +02:00
parent 99b61c4b2d
commit 95d6396dfa
7 changed files with 204 additions and 129 deletions

View File

@@ -7,7 +7,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
mSprite = new AnimatedSprite(texture, renderer, file);
disable();
mEnabled = true;
mEnabled = true;
switch (kind)
{
@@ -225,7 +225,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
// Valores para el efecto de rebote
mBouncing.enabled = false;
mBouncing.counter = 0;
mBouncing.speed = 0;
mBouncing.speed = 2;
mBouncing.zoomW = 1.0f;
mBouncing.zoomH = 1.0f;
mBouncing.despX = 0.0f;
@@ -252,18 +252,12 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
mStoppedCounter = 0;
mBlinking = false;
mVisible = true;
mInvulnerable = false;
mInvulnerable = true;
mBeingCreated = true;
mCreationCounter = creationtimer;
mCreationCounterIni = creationtimer;
mCreationCounter = creationtimer;
mCreationCounterIni = creationtimer;
mPopping = false;
mBouncing.enabled = false;
mBouncing.counter = 0;
mBouncing.speed = 2;
mBouncing.zoomW = 1;
mBouncing.zoomH = 1;
mBouncing.despX = 0;
mBouncing.despY = 0;
mCounter = 0;
mTravelY = 1.0f;
mSpeed = speed;
@@ -438,7 +432,7 @@ void Balloon::disable()
mSpeed = 0;
mStopped = false;
mStoppedCounter = 0;
//mTimeToLive = 0;
// mTimeToLive = 0;
mTravelY = 0;
mVelX = 0.0f;
mVelY = 0.0f;
@@ -483,8 +477,8 @@ void Balloon::updateState()
setStop(true);
if (mSprite->animationIsCompleted())
{
//mSprite->setAnimationCompleted(BALLOON_POP_ANIMATION, false);
//mTimeToLive = 0;
// mSprite->setAnimationCompleted(BALLOON_POP_ANIMATION, false);
// mTimeToLive = 0;
disable();
}
/*else if (mTimeToLive > 0)
@@ -571,6 +565,20 @@ void Balloon::updateState()
// Establece la animación correspondiente al estado
void Balloon::updateAnimation()
{
std::string creatingAnimation = "blue";
std::string normalAnimation = "orange";
if (mKind == POWER_BALL)
{
creatingAnimation = "powerball";
normalAnimation = "powerball";
}
else if (getClass() == HEXAGON_CLASS)
{
creatingAnimation = "red";
normalAnimation = "green";
}
// Establece el frame de animación
if (isPopping())
{
@@ -578,11 +586,11 @@ void Balloon::updateAnimation()
}
else if (isBeingCreated())
{
mSprite->setCurrentAnimation("blue");
mSprite->setCurrentAnimation(creatingAnimation);
}
else
{
mSprite->setCurrentAnimation("orange");
mSprite->setCurrentAnimation(normalAnimation);
}
mSprite->animate();