#155002 - Polaris - Wed Apr 23, 2008 9:35 pm
Recently I have been trying to make animated sprites and fortunately it wasn't much different from what I have originally envisioned. But still, I have several doubts about the whole thing.
First are the actual animation methods. I figured out two different ways of doing it.
The first one was loading all the tiles for any given sprite, and then changing the tileIdx property of the SpriteEntry asociated with them to achieve the animation.
The second method is very similar but instead of loading all the tiles at once, I just load the needed ones for each frame. So I end up doing a dmaCopy each time a frame goes by.
I'm assuming the first method is faster since it doesn't require to constantly make dmaCopy, but it also takes a lot more space in memory. Is the faster speed worth it? Or the difference is negligible?
With that out of the way I still don't know how should I use grit properly to convert my sprite sheets.
In the small test i'm currently doing, I figured out I needed to place all the frames of my animation making a column rather than a row in my .png file, so that grit would tile it properly for any of the two previous methods to work.
Which commads should I use so that I can have grit tile the image properly, regardless of how I choose to draw the frames in my image file.
Lastly there is the issue of having a game entity use different animations from the same sprite sheet.
So I thought about it for a moment and after some research I figured I needed two things in order to make this. First I should know where each individual animation starts and where it finishes(in the sprite sheet) and second, a state machine so that I can manage more easiely the transitions between each animation.
The state machine part sounds great. What doesn't sound so great is having to look at the sprite sheets and taking note of the numbers of the frames each animation starts and ends with.
I'm pretty sure it's going to work. Each state would take care of setting the current beginFrame and endFrame and then with those two crucial numbers I could set up a very crud Animation Manager to handle the animation code for every sprite.
Still there is a voice in the back of my head, it's mumbling, I want to shut it, but I can't. It's saying "Hardcoding........".
What would be a better aproach to get different animations out of a single sprite sheet?
First are the actual animation methods. I figured out two different ways of doing it.
The first one was loading all the tiles for any given sprite, and then changing the tileIdx property of the SpriteEntry asociated with them to achieve the animation.
The second method is very similar but instead of loading all the tiles at once, I just load the needed ones for each frame. So I end up doing a dmaCopy each time a frame goes by.
I'm assuming the first method is faster since it doesn't require to constantly make dmaCopy, but it also takes a lot more space in memory. Is the faster speed worth it? Or the difference is negligible?
With that out of the way I still don't know how should I use grit properly to convert my sprite sheets.
In the small test i'm currently doing, I figured out I needed to place all the frames of my animation making a column rather than a row in my .png file, so that grit would tile it properly for any of the two previous methods to work.
Which commads should I use so that I can have grit tile the image properly, regardless of how I choose to draw the frames in my image file.
Lastly there is the issue of having a game entity use different animations from the same sprite sheet.
So I thought about it for a moment and after some research I figured I needed two things in order to make this. First I should know where each individual animation starts and where it finishes(in the sprite sheet) and second, a state machine so that I can manage more easiely the transitions between each animation.
The state machine part sounds great. What doesn't sound so great is having to look at the sprite sheets and taking note of the numbers of the frames each animation starts and ends with.
I'm pretty sure it's going to work. Each state would take care of setting the current beginFrame and endFrame and then with those two crucial numbers I could set up a very crud Animation Manager to handle the animation code for every sprite.
Still there is a voice in the back of my head, it's mumbling, I want to shut it, but I can't. It's saying "Hardcoding........".
What would be a better aproach to get different animations out of a single sprite sheet?