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

2014/4/1

Checking for another actor isnt in the world

trias95 trias95

2014/4/1

#
So i'm trying to make a boss level on my zombie game and the way i have the spawning of the zombies laid out at the minute is that they all work on a timer E.G. you fight for 60 seconds, break for 30. However with the addition of a boss, this method no longer works as i do not wish to assign only X amount of time to kill the boss in because if you dont kill it in that period of time then other things are gonna start coming and its gonna be messy. I assume i can use a list but im looking for the code that i can place in an actor to do something if that list's length is 0 Something along the lines of if("list of bosses in world".length > 0) { timer pause } Is there something along the lines of this in greenfoot? Thanks :)
trias95 trias95

2014/4/1

#
ive just had the idea of making the spawner image the same size as my world and placing it in the center. Since its a blank image. it then blankets the page. then i could use some code like
if (this.isTouching(boss.class) == true)
{
   //pause timer
}
if (this.isTouching(boss.class) == false)
{
   //unpause timer
}
im going to try it and report back.
danpost danpost

2014/4/1

#
You could always use:
if (getWorld().getObjects(boss.class).isEmpty()) ... else ...
trias95 trias95

2014/4/1

#
Turned out my method worked however the method you have shown me is the correct one so i will head back and change it later or at the least, ensure that when trying to check for a class in the world in future, i do it properly. Thanks again danpost :)
You need to login to post a reply.