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

2014/3/31

cannot find symbol - method getObjects

trias95 trias95

2014/3/31

#
Any idea why im getting this?
 if (getObjects(room1check.class).isEmpty()) {  
        //do stuff
    }  
danpost danpost

2014/3/31

#
Is that code in a World class?
trias95 trias95

2014/3/31

#
No, an actor class.
danpost danpost

2014/3/31

#
'getObjects' is a World class method, not an Actor class method. It must be executed on a World object. Since 'this', which is the object when none is given, is an Actor object, the compiler expects a method of the Actor class. 'getWorld' is an Actor class method that returns the World object you wish to execute 'getObjects' on.
trias95 trias95

2014/3/31

#
Hmm okay. What im trying to do is that i have two worlds and i need the zombies to spawn from different areas depending on the world they are in. to do this i decided to add an 'if' statement before the spawning code but i need that if to check if an actor specific to each world exists. so for example. i will place a blank actor in the first room called room1check and the if statement needs to see if it is in the world, if it is then it can spawn zombies from location A, B, and C. and if its im room 2 there will be an actor called room2check that if found by the if statement to exist, will allow zombies from points D, E and F as opposed to A, B and C.
You need to login to post a reply.