Microsoft MakeCode

Problem with flipping animations

image

I made this game to show a problem I have with other games I am making. So the code works when you press the left button. The block doesn’t change and the blue stripe on it faces left.

image

And when you press the right button, the animation flips.

image

image

But when you press the right button again, it flips it back over to facing left

image

It seems like it is flipping the animation over and over again. How do I make it flip only when it was facing a different direction? Like when you press the right button it won’t flip if it is already facing right.

https://makecode.com/_iPvR2hYMyTjL

I made a copy of the the animation by cloning all the images, and flipped those, and just use that as a right animation!

(the issue was the code ALWAYS flips the animation, even if the animation was already flipped, which is why I just made one copy of it. You could also fix it by keeping a variable to track which direction you are facing, and only flip it when necessary)

1 Like

Ok, thank you! Now the block flips just how it should be! (not always)

well it seems to me that every time you pressed the right button you were flipping the animation backwards, so even in pressing right, you’re turning it back to left, and then to right, and then to left. it’s a permanent change to the sprite animation. i just set it all up in the on start event.

2 Likes

Thank you too @drtongue96

1 Like