Welcome! Log In Create A New Profile

Advanced

Libwiisprite: Flipping Sprites Horizontally

Posted by Arikado 
Libwiisprite: Flipping Sprites Horizontally
February 15, 2009 04:30PM
Could someone provide me an example of flipping of libwiisprite Sprite horizontally? For example, I'm writing a platformer so when I press left I need to flip the Sprite horizontally to make it look like the character changed directions without the need for additional art. 180 degree rotations dont accomplish this. I'm thinking maybe use the reference pixel member of the sprite class?

Thanks in advance to any and all replies I recieve. All help is greatly appreciated.

-Arikado



Edited 1 time(s). Last edit at 02/15/2009 04:31PM by Arikado.
Re: Libwiisprite: Flipping Sprites Horizontally
February 15, 2009 05:27PM
sprite.SetTransform(1); = mirror image = sprite.SetTransform(TRANS_MIRROR );
sprite.SetTransform(0); = right-way-up = sprite.SetTransform(TRANS_NONE );

Hope that helps!
Re: Libwiisprite: Flipping Sprites Horizontally
February 15, 2009 05:33PM
Thank you very much. Could you please elaborate on what "mirror image" and "right-way-up" are? Are they just additional images or something else?
Re: Libwiisprite: Flipping Sprites Horizontally
February 15, 2009 05:41PM
Sorry, my bad. The Equals wasn't a code operator. What I meant was:

sprite.SetTransform(1); // This flips "sprite" horizontally
sprite.SetTransform(0); // This restores "sprite" to normal orientation
sprite.SetTransform(TRANS_MIRROR ); // This does the same as SetTransform(1)
sprite.SetTransform(TRANS_NONE ); // This does the same as SetTransform(0)
Re: Libwiisprite: Flipping Sprites Horizontally
February 15, 2009 06:12PM
Thanks a ton. It worked like a charm!
Re: Libwiisprite: Flipping Sprites Horizontally
February 22, 2009 08:40PM
And flipping vertical is rotating 180 + horizontal mirror? Or does a shorter way exist.



Edited 1 time(s). Last edit at 02/22/2009 08:40PM by Dykam.
Re: Libwiisprite: Flipping Sprites Horizontally
February 22, 2009 11:14PM
Hi Dykam,

In the standard code release of LibWiiSprite, yes, that's the way to do it. Of course, if you have the source, it's not much work (and much more run-time-efficient) to include an extra enumeration value to make a direct transform for vertical flipping! This does mean you have four different draw options (normal, flipped horizontal, flipped vertical and flipped both), which would increase the size of your object code a little, but (a) probably not enough to seriously damage your load times or memory expense, and (b) offsettable by rewriting the draw code to reduce the number GX function calls (hint - use integer variables to provide your table indices!).
Sorry, only registered users may post in this forum.

Click here to login