import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Rocket extends Actor { private Actor actor; public Rocket() { setRotation(270); } /** * Act - do whatever the Rocket wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { moveRocket(); checkEdge(); seePlane(); } public void moveRocket() { move(10); } public void checkEdge() { if (getY() <= 0) { getWorld().removeObject(this); } } public void seePlane() { if (getOneIntersectingObject(Plane.class) != null) { Greenfoot.playSound("Explosion.mp3"); } } }
if (getOneIntersectingObject(Plane.class) != null)