GML Fail in programming a flip of sprite

Hi community !

I'm french and it's my first post here so i'm sorry for my english mistake.

I've a problem with my code for flip my character in my first platformer game.

Here's my code for flip :

if (hspd != 0)
    image_xscale = sign(hspd)
My normal character :


and when i want to flip :


The ratio is destroyed xD

Can someone tell me how can i fix that ?

Thanks everyone ^^

Loïc Mouton
Save your characters default scale in a variable in the Create Event. Then use that value * sign(hspd) when setting the image_xscale.


Forum Staff
There is no way for sign to return anything but -1, 0 or 1. Are you sure that the code you posted is causing this? Are you changing the scaling of this sprite anywhere else?
I'm assuming that your default image scale is smaller than 1 and on the stretched image it's got -1 x and something like .5 y
I've used the solutions of IndianaBones and it's work better ! Thanks you all for your answer !

Here is the code for those who have the same problem in the future :

In create event :
scale_x = image_xscale
In step event :
if (hspd != 0)
    image_xscale = scale_x *sign(hspd)