Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
up vote 1 down vote accepted

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 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
      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.[]

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.