Navigation

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

    How to flip sprite

    Coding
    7
    11
    690
    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.
    • SteveZX81
      SteveZX81 F last edited by

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team last edited by

        Yes you can rotate and scale in the image editor. Select the part of the image then ZL (More) -> A (Paste) -> ZL (More) you can then scale and rotate using left/right on the left stick/pad and scale using up/down.

        A 1 Reply Last reply Reply Quote 0
        • A
          AtomAlexander F @pianofire last edited by

          @pianofire I know I can scale and rotate but can I design half a sprite then copy and flip the sprite from left to right like in smilebasic?

          Martin 1 Reply Last reply Reply Quote 0
          • pianofire
            pianofire Fuze Team last edited by pianofire

            There is no flipSprite function but you can do it using a negative scale e.g.

            setSpriteScale(sprite, sprite.xscale * -1, sprite.yscale)
            

            Will flip it in the x axis

            1 Reply Last reply Reply Quote 1
            • Martin
              Martin Fuze Team @AtomAlexander last edited by

              @AtomAlexander said in How to flip sprite:

              @pianofire I know I can scale and rotate but can I design half a sprite then copy and flip the sprite from left to right like in smilebasic?

              Bear in mind that we may not know what you can or can’t do in other programs since we may not own them!

              A 1 Reply Last reply Reply Quote 0
              • A
                AtomAlexander F @Martin last edited by

                @Martin i completely understand that I was just using smilebasice as an example to get across the function I was trying to preform in the best way I could think of

                1 Reply Last reply Reply Quote 0
                • Dave
                  Dave Fuze Team last edited by

                  In order to flip only half of your sprite, you will need to separate your sprite image into two separate images, then effectively "combine" them in your code - by always performing operations on both of the halves which make up the whole.

                  In terms of simply flipping, I tend to create a sprite property to store the direction it's facing:

                  right = 0
                  left = 1
                  
                  spr = createSprite()
                  spr.facing = right
                  spr.scale = {1, 1}
                  

                  Then, in your program:

                  if spr.facing == left then
                      spr.scale.x = -spr.scale.x
                  else
                      spr.scale.x = 1 // or whatever your original scale is
                  endif
                  
                  setSpriteScale(spr, spr.scale)
                  

                  It might not be the prettiest way, but it works for me!

                  1 Reply Last reply Reply Quote 0
                  • M
                    MikeDX last edited by

                    you don't need to call setspritescale() if using spr.scale

                    setspritescale(sprite, value)
                    

                    is the same thing as

                    sprite.scale = value
                    
                    Dave 1 Reply Last reply Reply Quote 2
                    • waldron
                      waldron F last edited by

                      i could argue quite strongly on being able to flip invert sprites while drawing them especially when drawing pixel by pixel, it would save me a heap of time on symmetric artwork

                      1 Reply Last reply Reply Quote 0
                      • Dave
                        Dave Fuze Team @MikeDX last edited by

                        @MikeDX Thanks! I never actually tried it without... ;^_^

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