Skip to main content
added 22 characters in body
Source Link
Tetrad
  • 30.1k
  • 12
  • 96
  • 143

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 ;)

{

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

{

}
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]

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]

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]

Source Link
Ayyappa
  • 870
  • 5
  • 13

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]