How to flip sprite
-
This post is deleted! -
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.
-
@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?
-
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
-
@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!
-
@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
-
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!
-
you don't need to call setspritescale() if using spr.scale
setspritescale(sprite, value)
is the same thing as
sprite.scale = value
-
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
-
@MikeDX Thanks! I never actually tried it without... ;^_^