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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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] );; } |