Hi, i´m new at this forum. I´m a german student at a school...i think the British equivalent are the A-Levels. Well, i got a little bit knowledge about Java (with Greefoot) in the subject "Technology/IT" and now everyone should make a little game-project. And obviously i have a problem.
I wanted to animate my boss with this code:
The problem is, that there are moments where no frame is shown. In the animations this results in flickering. I tried to handle this problem by adding more frames/images and it got better, but this doesn´t work very well.
Thanks to the inventors of Greenfoot and for this forum and sorry for my English^^
alex
GreenfootImage[] images = new GreenfootImage[241];
int imageNumber;
public Boss()
{
for( int i=1; i<images.length; i++ ) images[i] = new GreenfootImage( "" + i + ".png" );
setImage( images[imageNumber] );
}
public void act()
{
{
java.util.List<Player/**Name Objekt**/> playersInWorld = getWorld().getObjects(Player.class);
if (!playersInWorld.isEmpty())
{
Player varplayer = playersInWorld.get(0);
SchauzuSpieler(varplayer);
moveToPlayer(varplayer);
UmWand();
Health();
}
}
animation();
}
public void animation()
{
imageNumber = ( imageNumber + 1 ) % images.length;
setImage( images[imageNumber] );;
}

