How can i flip my character left or right
-
Originally i had code that went```
If c.left then
player.x -= movespd
player.rotation = 180
endifBut obviously that made my sprite flip upside down when i tried to walk left so I looked at one of the posts on this forum of being able to symmetrically flip half a sprite then edit it to flip the whole sprite which lead me to this:
right = 0
left = 1
If c.left then
player.x -= movespd
player.facing = left
player.xscale = -player.xscale
endifBut this just made it flick between facing left and right and I am just coming back from fuze after a little while and I am just stumped on how to flip the sprite fully.
-
You'll probably want to add another property to your sprite called something like player.wasFacing so you can check if the direction they are facing has changed and only flip the sprite if it has. So maybe something like:
right = 0 left = 1 if c.left then player.x -= movespd player.facing = left endif if player.facing != player.wasFacing then player.xscale = -player.xscale endif // put this near the end of your loop player.wasFacing = player.facing
There may be a more elegant solution or way to write it but that's what I would do :)