Hey , i just started with greenfoot and made a Space Infinity Runner with a Spaceship that is only Moving in the X-axis but not on the Y . Now i wanted to ask how i could animate it with 5 photos when the game starts , even when its not moving .
// fields
GreenfootImage[] images = new GreenfootImage[5]; //array for images (loaded in the constructor of the class or here)
int imageCounter;
// act
public void act()
{
imageCounter = (imageCounter+1)%(5*6); // 5 images, 6 frames per image
if (imageCounter%6 == 0) // time to change image
{
setImage(images[imageCounter/6]); // set new image
}
// other actions (moving)
}