animated sprite
Monkey Forums/Monkey Beginners/animated sprite
| ||
Just a query. If I understand correctly: To display a animated sprite (several frames worth) the sprite sheet must be a horizontal strip that divides perfectly.. so if I had a sprite that is 50x50 pixels in size, with a total of 4 frames, then the file should be 50x200, is that correct? And within the "DrawImage" function, I set "frame:Int=3" to display the last frame? (or have I misunderstood?) |
| ||
if you want the DrawImage-Function with the frames, you are correct BR Wyl |
| ||
Yes. But of course you're not obliged to use frames, you can use separate sprites if you prefer to organise the layout yourself. |
| ||
You can also use GrabImage:Image(...) to grab a part of an image. |
| ||
Your sprites needn't be in one single row. You can do multiple rows, and the count simply increases horizontally, then vertically. If you're aiming for multiple targets, it's good practice to keep within "power of two" sizes for your full image. 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024 or at a push, 2048x2048 (Although older systems will choke at 2048x2048 and beyond, so take care.) Using none-standard sizes might randomly fail on certain targets without any rhyme or reason, so it's best to stick to what works, lest things break unexpectedly. Within the grid, you can use any size you wish, but multiples tend to work better, since they fit better on the spritesheet. |
| ||
I have always been skeptical about the atlas having to be a square. I know that the image has to be a power of 2 but not a square. I recall a few years ago reading a thread on a forum with some quite knowledgable programmers stating that the image could be a rectangle as long as it was a power of 2 such us 128x64, 256x32 etc. I wish I could remember where I read it but I can't recall for the life of me. In Retrospect BlitzMax also does that to the images before sending them to the graphics card. Images get resized to a power of 2 but not necessarily a square. Its clearly visible by looking at the BlitzMax module source. I am not saying that I have the answer but if somebody here knows I would appreciate any comments. |
| ||
Yeah, rectangles work just as well, but in my experience, if you're stuffing all your sprites into sheets, you may as well leave space for expansion. Squares usually end up with gaps that you can fill in later! |
| ||
It's reasonable and won't argue that point as I randomly do either or depending on how I feel that day. |
| ||
I don't recall anyone ever saying it had to be a square. |
| ||
The square power of two question was asked on http://gamedev.stackexchange.com/a/26189 Of course there still is a limit to the size of a texture. |
| ||
I don't recall anyone ever saying it had to be a square. of course not! |