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

2013/1/14

How to stop the game

Bestgirl Bestgirl

2013/1/14

#
How to stop the game when the spider eat the chicken import greenfoot.*; public class Spider extends Actor { // GLOBAL DECLARATIONS // =================== // var declarations may go here // CONSTRUCTOR SUBPROGRAM // ====================== public Spider() { // code here runs one time only } // end constructor // ACT METHOD // ======================== public void act() { eat(); turn(2); move(3); } // end act public void eat() { Actor chicken; chicken= getOneIntersectingObject(Chicken.class); if(chicken !=null) { getWorld().removeObject(chicken) ; }//end if }//end of eat } // end of class
Gevater_Tod4711 Gevater_Tod4711

2013/1/14

#
Use the method Greenfoot.stop(); That will pause the execution of the game.
bbwf bbwf

2013/1/14

#
What gevater said. When the chicken equals a null and gets removed put Greenfoot.stop();
You need to login to post a reply.