# Flipping the sprite image issue

**URL:** <https://forum.makecode.com/t/flipping-the-sprite-image-issue/1038>\
**Category:** Arcade\
**Created:** [January 13, 2020, 2:09pm UTC](https://forum.makecode.com/t/flipping-the-sprite-image-issue/1038 "2020-01-13T14:09:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![izno](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@izno](https://forum.makecode.com/u/izno)\
**Post date:** [January 13, 2020, 2:09pm UTC](https://forum.makecode.com/t/flipping-the-sprite-image-issue/1038/1 "2020-01-13T14:09:41Z")

</div>

Hello all,

I’m a new user…

Flipping the sprite image with the component “flip horizontally” seems to be broken.

TEST: Holding down the left-arrow result in flickering jump between the original image and the flipped one. Also, after releasing the left-arrow – the direction of the image can be flipped even the “on game update” should set the image to the original direction.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/867a9965ccf922d5e42567147f536024101d8503.jpeg)

…or have I missed something since the update?

Thank you in advanced

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 13, 2020, 7:25pm UTC](https://forum.makecode.com/t/flipping-the-sprite-image-issue/1038/2 "2020-01-13T19:25:10Z")

</div>

The issue here is that when you set the player’s image, it stays the same between game updates. So every time a game update happens and the velocity is less than zero, you are flipping the image so that it alternates between left, right, left, right, etc. (that’s why you get a flickering effect).

To fix it, you only want to change direction when the velocity _changes_ from positive to negative. In other words, you should only flip the image on the _first_ game update where the velocity has changed. Here’s a code snippet that does this by storing the player’s direction in a variable:

 ![Screen Shot 2020-01-13 at 11.19.07 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/9ba73d9132bedd5c01c68a6965e05a66c9518ca6.png)

and here’s a link to the code: [https://makecode.com/\_613UMfMbMHjX](https://makecode.com/_613UMfMbMHjX)

---

<div class="post-metadata">

**Author:** ![izno](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@izno](https://forum.makecode.com/u/izno)\
**Post date:** [January 14, 2020, 7:51am UTC](https://forum.makecode.com/t/flipping-the-sprite-image-issue/1038/3 "2020-01-14T07:51:30Z")

</div>

Thanks for the solution…

However, what I don’t understand is how the velocity and move with button work?

Holding down left-arrow should result in -100 constantly, but when I log the value it changes irregularly between -100 & 0! It doesn’t really make sense… how can the player move to left when the move/velocity value is positive?

Thank you in advance.
