# Problem with flipping animations

**URL:** https://forum.makecode.com/t/problem-with-flipping-animations/11159
**Category:** Help
**Created:** [November 30, 2021, 7:45pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159 "2021-11-30T19:45:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)
#### Post date: [November 30, 2021, 7:45pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/1 "2021-11-30T19:45:36Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/ea5426fa52ae1d71d93e5ce9f6aabe486af48e83.png)

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](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/ad37dfa1406617409963d13dd1aa843688b2a7de.png)

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

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8a0061abd195f87ea277132d4b4880df7affa662.png)

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b07fb045bfdf549240a578deb2efceed44c59e8b.png)

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

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8451f7970c6eaa3dccb49759c5889450f7ffa247.png)

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.

> **[what is wrong with this code](https://arcade.makecode.com/76689-69970-95204-88266)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![livcheerful](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/livcheerful/32/3509_2.png) [@livcheerful](https://forum.makecode.com/u/livcheerful)
#### Post date: [November 30, 2021, 10:34pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/3 "2021-11-30T22:34:52Z")

</div>

[https://makecode.com/\_iPvR2hYMyTjL](https://makecode.com/_E00TkLEsRHt8)

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

---

<div class="post-metadata">

### Author: ![livcheerful](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/livcheerful/32/3509_2.png) [@livcheerful](https://forum.makecode.com/u/livcheerful)
#### Post date: [November 30, 2021, 10:36pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/4 "2021-11-30T22:36:20Z")

</div>

(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)

---

<div class="post-metadata">

### Author: ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)
#### Post date: [November 30, 2021, 10:41pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/5 "2021-11-30T22:41:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![drtongue96](https://avatars.discourse-cdn.com/v4/letter/d/ed8c4c/32.png) [@drtongue96](https://forum.makecode.com/u/drtongue96)
#### Post date: [November 30, 2021, 10:57pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/6 "2021-11-30T22:57:05Z")

</div>

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.

> **[what is wrong with this code (fix maybe?)](https://arcade.makecode.com/06289-01994-79083-08929)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![TheJaky](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/thejaky/32/5711_2.png) [@TheJaky](https://forum.makecode.com/u/TheJaky)
#### Post date: [November 30, 2021, 11:22pm UTC](https://forum.makecode.com/t/problem-with-flipping-animations/11159/7 "2021-11-30T23:22:10Z")

</div>

Thank you too @drtongue96
