Flipping an Image
Moderators: Shine, Insert_witty_name
Flipping an Image
I searched but couldn't find any help.
What i'm doing is a 2D fighting game. i have all my sprites but they all face right. i need to start the game with on of the sprite flipped and facing left(so both sprites are facing center) but i dont know how?
is it something i need to do while blitting the images?
thanks for any help=]
what i have been using is
screen:blit(150,120,image, 0,0,image:width() * - 1, image:height(), true)
What i'm doing is a 2D fighting game. i have all my sprites but they all face right. i need to start the game with on of the sprite flipped and facing left(so both sprites are facing center) but i dont know how?
is it something i need to do while blitting the images?
thanks for any help=]
what i have been using is
screen:blit(150,120,image, 0,0,image:width() * - 1, image:height(), true)
-
- Posts: 31
- Joined: Sat Mar 04, 2006 1:35 am
It's possible to flip images but it would be quite slow using Lua. Basically you would create an empty image with the same dimensions as your img. The use the image:pixel(x, y) function to check the color of the pixel in an img but instead of using x you would use img.width - x. You would have to do this over the enitre img!
Re: Flipping an Image
It's ugly, and will use more RAM, load times will be longer, but this should work.Hopper wrote:I searched but couldn't find any help.
What i'm doing is a 2D fighting game. i have all my sprites but they all face right. i need to start the game with on of the sprite flipped and facing left(so both sprites are facing center) but i dont know how?
is it something i need to do while blitting the images?
thanks for any help=]
what i have been using is
screen:blit(150,120,image, 0,0,image:width() * - 1, image:height(), true)
Create a new image the same size as the image you want to flip.
Use a for loop from 0 to the image height, then one from 0 to the width.
Then do what matriculated said, but instead of blitting it to the screen, blit it to the new image.
Like I said, it's going to use twice the RAM, and images in luaplayer take up quite a bit of RAM (one full screen picture = ~1MB).
I really suggest learning C and taking luaplayer's graphics.c, or possibly using the OldSchool library. It has a function built in to flip images (but I won't use it because it's not open source :().
Edit: I just realized matriculated said the exact same thing I did.. oh well, still look into the C thing :)
-
- Posts: 31
- Joined: Sat Mar 04, 2006 1:35 am
-
- Posts: 64
- Joined: Fri Jul 15, 2005 11:44 pm