
Hello,
I'm trying to recreate a PONG game and would like to animate (expand) the paddles vertically when the ball collides with them.
I have a Sprite class with this Animate method:
public void Animate() // start animation loop when ball collides
{
animationActive = true; // while bool is true play the sprite frames
while (animationActive)
{
++currentFrame.X;
if (currentFrame.X >= sheetSize.X)
{
currentFrame.X = 0;
++currentFrame.Y;
if (currentFrame.Y >= sheetSize.Y)
{
currentFrame.Y = 0;
animationActive = false;
}
}
}
}
As you can imagine. My problem is the animation doesn't play when the ball hits the paddle.
For checking the collision i have a collide method that i call in the Update() like this:
if (collideP1())
player1.Animate();
Thanks for the help.