Flipping the sprite image issue

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.

…or have I missed something since the update?

Thank you in advanced

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:

and here’s a link to the code: https://makecode.com/_613UMfMbMHjX

1 Like

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.