• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

Help with Flipping Sprite

Hi! I'm trying to make a game (using a Youtube tutorial) and the code he used to flip his Sprite was
if (hsp != 0) image_xscale = sign(hsp); (HSP Stands for Horizontal Speed) but when I use it my sprite flips but it Makes my Character thin and squished. any help would be greatly appreciated.
 

zATARA_0

Member
sign should only be able to return -1 or 1. It sounds like somehow you are setting your x scale to a decimel value.
 

samspade

Member
Hi! I'm trying to make a game (using a Youtube tutorial) and the code he used to flip his Sprite was
if (hsp != 0) image_xscale = sign(hsp); (HSP Stands for Horizontal Speed) but when I use it my sprite flips but it Makes my Character thin and squished. any help would be greatly appreciated.
sign returns -1, 0, or 1 depending upon whether the number you give it is negative, 0, or positive (respectively). Since you prevent the number from being 0 (by saying if (hsp != 0) the only values it can return are 1 or -1. My guess is that you've scaled your sprite to a different value somewhere - for example you've stretched it to a different size in the room editor or you have written code, perhaps in the create event, that says image_xscale = 3. Your image_xscale = sign(hsp) line then overwrites that.
 
Top