Okay, so i made a missile, the thing is I need it to make an explosion animation upon colliding into a vehicle, the missile is the actor that'll explode and animate so if anyone knows how 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | public void act() { Actor a = this .getOneIntersectingObject(Vehicle. class ); if ( a != null ) { Greenfoot.playSound( "Explosion.mp3" ); this .setImage( "Explosion.png" ); Greenfoot.delay( 5 ); World myWorld = getWorld(); CarWorld carworld = (CarWorld)myWorld; Counter counter = carworld.getCounter(); counter.addScore2(); getWorld().removeObject( this ); return ; } Actor b = this .getOneIntersectingObject(Cop. class ); if ( b != null ) { Greenfoot.playSound( "Explosion.mp3" ); this .setImage( "Explosion.png" ); Greenfoot.delay( 5 ); getWorld().removeObject( this ); World myWorld = getWorld(); CarWorld carworld = (CarWorld)myWorld; Counter counter = carworld.getCounter(); counter.addScore2(); return ; } turn( 10 ); setLocation(getX(), getY()- 4 ); if ( getY() <= 0 ) getWorld().removeObject( this ); } } |