Help with Flipping Sprite

B

BruhTheStatement

Guest
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.
 
B

BruhTheStatement

Guest
Thank you Samspade. that was my problem then. I stretched my sprite in the Room Editor.
 
B

BruhTheStatement

Guest
Also, Quick Question. What is the Recommended size for a Sprite So I can make a proper Platformer?
 
Top