This site requires JavaScript, please enable it in your browser!
Greenfoot back
Ototo
Ototo wrote ...

2018/3/13

How to use 2 Gif's in one Actor?

1
2
Ototo Ototo

2018/3/14

#
public class Spieler extends Actor { GifImage ImageGif = new GifImage("walknoweapons.gif"); GreenfootSound blop = new GreenfootSound("Blop-Mark_DiAngelo-79054334.mp3"); GreenfootSound woosh = new GreenfootSound("Woosh-Mark_DiAngelo-4778593.mp3"); private int ySpeed; private int apexTimer; private int count = 0; private Healthbar healthbar; private Staminabar staminabar; private GifImage ImageGif2; private GifImage currentGif; private GifImage stopAttackAtImage; boolean spaceKeyIsDown = false; boolean atStopImage = false; public void attack() { if (Staminabar.stamina > 0) { if (Greenfoot.isKeyDown("e") && currentGif == ImageGif) { ImageGif2 = new GifImage("character-horizontal-attack-moving.gif"); currentGif = ImageGif2; stopAttackAtImage = getCurrentImage(); atStopImage = true; } setImage(getCurrentImage()); if (currentGif == ImageGif2 && atStopImage != (stopAttackAtImage == getImage())) { atStopImage = !atStopImage; if (atStopImage) currentGif = ImageGif; } } } }
danpost danpost

2018/3/14

#
Please use code tags when posting code. Also, do not just say "I got an error". Specify what error you got and indicate exactly what line it occurred on. In you field declaration area, modify to the following:
1
private GifImage currentGif = ImageGif;
and
1
private GreenfootImage stopAttackAtImage;
danpost danpost

2018/3/14

#
Anywhere you have 'getCurrentImage()', change it to 'currentGif.getCurrentImage()'.
Ototo Ototo

2018/3/14

#
Well, there are no Syntax errors any longer... but when i press "e" the Game stops.
Ototo Ototo

2018/3/14

#
Nvm... Thank you so much ! I Love you !!!
You need to login to post a reply.
1
2