fix: els globos apareixien un frame mal situats al crearse desde un pare
This commit is contained in:
@@ -175,23 +175,22 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
||||
const auto SIZE = static_cast<Balloon::Size>(static_cast<int>(balloon->getSize()) - 1);
|
||||
const int PARENT_HEIGHT = balloon->getHeight();
|
||||
const int CHILD_HEIGHT = Balloon::WIDTH.at(static_cast<int>(balloon->getSize()) - 1);
|
||||
const int Y = balloon->getPosY() + (PARENT_HEIGHT - CHILD_HEIGHT) / 2;
|
||||
const int X = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + 2 * (balloon->getWidth() / 3);
|
||||
const int CHILD_WIDTH = CHILD_HEIGHT;
|
||||
const float Y = balloon->getPosY() + ((PARENT_HEIGHT - CHILD_HEIGHT) / 2);
|
||||
float x = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + (2 * (balloon->getWidth() / 3));
|
||||
const float MIN_X = play_area_.x;
|
||||
const float MAX_X = play_area_.w - CHILD_WIDTH;
|
||||
x = std::clamp(x - (CHILD_WIDTH / 2), MIN_X, MAX_X);
|
||||
|
||||
// Crea el globo
|
||||
auto b = createBalloon(0, Y, balloon->getType(), SIZE, VX, balloon_speed_, 0);
|
||||
auto b = createBalloon(x, Y, balloon->getType(), SIZE, VX, balloon_speed_, 0);
|
||||
|
||||
// Establece parametros
|
||||
b->alignTo(X);
|
||||
b->setVelY(b->getType() == Balloon::Type::BALLOON ? -2.50F : Balloon::VELX_NEGATIVE * 2.0F);
|
||||
|
||||
// Herencia de estados
|
||||
if (balloon->isStopped()) {
|
||||
b->stop();
|
||||
}
|
||||
if (balloon->isUsingReversedColor()) {
|
||||
b->useReverseColor();
|
||||
}
|
||||
if (balloon->isStopped()) { b->stop(); }
|
||||
if (balloon->isUsingReversedColor()) { b->useReverseColor(); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user