GML Fail in programming a flip of sprite

L

Loïc Mouton

Guest
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 :

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

upload_2019-11-6_17-40-4.png

and when i want to flip :

upload_2019-11-6_17-41-2.png

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.
 

TsukaYuriko

☄️
Forum Staff
Moderator
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?
 
R

robproctor83

Guest
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
 
L

Loïc Mouton

Guest
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 :
Code:
scale_x = image_xscale
In step event :
Code:
if (hspd != 0)
{
    image_xscale = scale_x *sign(hspd)
}
 
Top