Hello again Greenfoot discussion form,
I am currently working on a game that involves a character that can drop bombs where he stands. I want the bombs to wait for a brief period of time and then explode showing an explosion image and removing all actors in the area it covers. My first instinct was using the canSee method but that only covers one object and I want to remove all of them.
Here is the code for the bomb class
If anyone has any ideas please help
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 class Bomb extends Actor { private int chargeTime; private int delay; private GreenfootImage egg; private GreenfootImage explosion; public Bomb(){ chargeTime = 10 ; delay = 0 ; egg= new GreenfootImage( "eggBomb.PNG" ); explosion = new GreenfootImage( "Explosion.PNG" ); setImage(egg); } public void act() { delay++; if (delay >= chargeTime) { setImage(explosion); //code for destroying all actors in the area would go here } } } |