# J2ME character animation with multiple sprite sheets

I'm working on a J2ME game and I want to have walking animations.

Each direction of walking has a separate sprite sheet (i.e. one for walking up, one for walking right etc), I also have a static idle image for each direction held together in a single file. I've tried to hold an array of sprites in my player class and then just drawing the sprite corresponding to the current direction, but this doesn't seem to work.

I'm aware that if I combine all the animations into one sprite sheet I could set up different animation sequences, but I want to be able to do it with separate images for each animation.

Is there a way that anyone knows of to achieve this? And ideally without too much extra code (as opposed to combining the sprites into one sheet)

As you said each direction of walking had a sprite sheet.Some thing like this structure will help.

Have the 0'th index as the static IDLE image.When you want to animate just update the animation Index to draw the rest of images in that sprite Sheet.

if(animate)//Just a rough code...you can optimize better ;)
{
animIndex++;//animIndex is the current Frame of the animation
draw(currentSpriteSheetImages[animIndex]);//currentSpriteSheetImages holds the set of images created from a sprite sheet
}
else
{
draw(currentSpriteSheetImages[0]);//drawing the idle image
animIndex = 0;
}


Btw, Just for some more info...As J2me devices have less memory,its better if you follow some thing which will create sprites with minimum memory footprint.I recommend you to check this useful tool.[http://www.motionwelder.com/tutorial.php]

• Thanks, I seem to have it working now. Half of the problem was a silly mistake on my end but thanks for clearing it up. And that Motion Welder tool looks quite interesting too, I'll make sure I check it out. – Alex Feb 15 '11 at 10:00