Hi guys.
So I have this entity which represents a tile which should flip when it is clicked on and reveal its other side. Now for the animation of “flipping” I figured I’d use ScaleY and scale it to 0 the back to 1 but with a different graphic.
Here is the code:
override public function update():void
{
if((collidePoint(x,y,FP.world.mouseX, FP.world.mouseY)) && !(_animating)) {
_animating = true;
flipTile();
}
}
The _animating is there so that it would only call the flipTile function once as needed.
public function flipTile():void
{
while(_Spritesheet.scaleY > 0){
_Spritesheet.scaleY -= 1 * FP.elapsed;
}
if(_faceDown) _Spritesheet.play(_tileID + "_face");
else _Spritesheet.play("back_face");
_Spritesheet.scaleY=0;
while(_Spritesheet.scaleY < 1){
_Spritesheet.scaleY += 1 * FP.elapsed;
}
_Spritesheet.scaleY=1;
_animating = false;
}
Now in my head I thought it should work but when I run it, it takes about 2 seconds(expectedly) to change to the new graphic, however it doesn’t actually "animate’ the flip. to shrink and then expand. I’m not sure if I’m doing it correctly and what I should do to have the correct behavior.