Hey there!
Okay I've got a fiew questions and a Source Code which is not running.
So first my Questions:
1.Can Greenfoot play Gifs?
2.Can i Scale images?
3.Is there any ShortCut that formats the Code automaticly like strg+shift+f in Eclipse?
4. How can i give Variable values to a other World in the same project (Hoghscore)
Okay now my problem:
I want that my Bomb explodes after 3 seconds.I'm writing the code which just removes the Bomb.But it deosn't work.
Here the Code of the Bomb.class:
And the Code which creates the Bomb:
I hope you can help me out!
Greetings
Marius
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public void act() { //Bomb bomb = (Bomb)this.getOneObjectAtOffset(0, 0, Bomb.class); bombCounter(); } public void destroyBomb() { getWorld().removeObject( this ); } public void bombCounter() { int timer = 100 ; if (timer> 0 ) { timer--; if (timer == 0 ) { destroyBomb(); timer = 100 ; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | nt RobX = getX(); int RobY = getY(); int counter = 0 ; if (bombs > 0 ) { getWorld().addObject( new Bomb(),RobX,RobY); if (bombs > 0 && Greenfoot.getKey() == "space" ){ bombs = bombs - 1 ; } else { bombs = 0 ; } } |