Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    How can i flip my character left or right

    Beginners
    2
    2
    377
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TwentyVyrus last edited by

      Originally i had code that went```
      If c.left then
      player.x -= movespd
      player.rotation = 180
      endif

      But 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
      endif

      But 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.
      1 Reply Last reply Reply Quote 0
      • Kat
        Kat Fuze Team last edited by

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

        1 Reply Last reply Reply Quote 3
        • First post
          Last post