I'm trying to make animated characters in lua but I'm having a problem. I have an image file with a tons of different sprites (all of them the same character), but not all of the sprites are the same size. I can't just put in a static number that divides up each frame neatly, like I've read in tutorials.
In this tutorial the programmer uses a tool called zwoptex to get them all the sprites the same size and aligned in a grid. Zwoptex doesn't run on Windows (at least not that I could find) so I read in the comments about another tool that does work for Windows called TexturePacker, but I can't find anyway to make them all the same size like in the tutorial. Does anyone know of a different way I could get these sprites to animate?
I hope I explained my question clearly.
Lua spritesheet troubles
I'm trying to make animated characters in lua but I'm having a problem. I have an image file with a tons of different sprites (all of them the same character), but not all of the sprites are the same size. I can't just put in a static number that divides up each frame neatly, like I've read in tutorials.
In this tutorial the programmer uses a tool called zwoptex to get them all the sprites the same size and aligned in a grid. Zwoptex doesn't run on Windows (at least not that I could find) so I read in the comments about another tool that does work for Windows called TexturePacker, but I can't find anyway to make them all the same size like in the tutorial. Does anyone know of a different way I could get these sprites to animate?
I hope I explained my question clearly.
Save a file next to the image file, that has the data you need. It could be as simple as a text file, or it could be more complex.
An example would be a text file where the first line is the image to read from, and each line afterward is a different frame, and contains the rectangle of pixels that contains that frame.
path/to/mySpriteSheet.png
5 5 20 50 //Starting at pixel (5,5), this frame is 20 pixels wide and 50 high.
40 15 10 80 //Starting at pixel (40, 15) this frame is 10 pixels wide and 80 high.
//etc... more frames go here
You might also want to add two more numbers, to be the location that the image is centered from.
You could have multiple text files all pointing to the same image... but each text file being a different animation.
Example:
myMainCharactor.png
idleAnimation.txt
attack1.txt
attack2.txt
jump.txt
falling.txt
kickInAir.txt
kick.txt
punch.txt
This is just food for thought; there are many different solutions you can come up with.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement