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

2015/10/19

I made this program, where a plane drops bombs every couple of seconds, but when it makes a bomb it stops moving here is my code:

sheshank sheshank

2015/10/19

#
import greenfoot.*; /** * Write a description of class plane here. * * @author (your name) * @version (a version number or a date) */ public class plane extends Actor { /** * Act - do whatever the plane wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ int a = 2;int isRight=0; public static final int MAX_DELAY = 50; int delay = 0; public void act() { if (delay < MAX_DELAY) { delay++; if(this.isAtEdge()){ if(isRight/2==1){ a=4; isRight=4; } else{ a=-4; isRight=2; } } return; } else { delay = 0; } Bomb Bomb = new Bomb(); Actor anchor = getOneObjectAtOffset(0,0,anchor.class); World world = getWorld(); world.addObject(Bomb, getX(),getY()); move(a); } }
danpost danpost

2015/10/19

#
You say "it stops moving", however, you have a plane, a bomb and the scenario as a whole. Which stops moving? If you are getting an error message, you should be posting the terminal printout. The problem does not appear to be in the class given -- maybe it is located in your Bomb class.
You need to login to post a reply.