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

2017/2/2

Need help with sharing variables across actors

WhiteWolf37 WhiteWolf37

2017/2/2

#
*/ public void act() { if (Greenfoot.mousePressed(this)) { World myWorld = getWorld(); MyWorld MyWorld = (MyWorld)myWorld; ecount Ecount = MyWorld.getEcount(); Ecount.spawn(); getWorld().removeObject(this); Actor Quit; Quit = getOneObjectAtOffset(0, 0, Quit.class); World world; world = getWorld(); world.removeObject(Quit); Actor menu; menu = getOneObjectAtOffset(0, 0, menu.class); world = getWorld(); world.removeObject(Quit); } } } //////////////////////////////////////////////////////////////////////MYWorld code public class MyWorld extends World { counterammo counter = new counterammo(); counterzombies counterz = new counterzombies(); ecount Ecount = new ecount(); public static boolean alive() { return alive(); } public ecount getEcount() { return Ecount; } public counterammo getCounter() { return counter; } public counterzombies getCounterz() { return counterz; } /** * Constructor for objects of class MyWorld. * */ public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1560,1024 , 1); boolean alive = true; //items //nt dropchance = Greenfoot.getRandomNumber(20); //addObject(new ammo(),1220,806); //walls addObject(counter, 70, 25); addObject(counterz, 70, 60); // adds Wall 2 into the scene addObject(new Wall2(),222,571); addObject(new Wall2(),222,765); addObject(new Wall2(),1348,534); addObject(new Wall2(),1348,922); addObject(new Wall2(),221,49); addObject(new Wall2(),938,417); //adds Wall 1 into the scene addObject(new Wall1(),586,292); addObject(new Wall1(),579,762); addObject(new Wall1(),915,759); addObject(new Wall1(),915,288); // adds Wall 3 into the scene addObject(new Wall3(),147,290); addObject(new Wall3(),867,219); addObject(new Wall3(),1,291); addObject(new Wall3(),330,833); addObject(new Wall3(),1170,121); //filling blocks //wall //addObject(new wall9(),1146,856); //characters //addObject(new bG1(),835,775); addObject(new menu(),780,512); addObject(new Start(),780,415); addObject(new Quit(),780,624); addObject(new Hero(),780,512); prepare(); }
Super_Hippo Super_Hippo

2017/2/2

#
What are you trying to do?
You need to login to post a reply.