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

2022/11/22

How to detect whether an object exists?

Logic_Greenfoot Logic_Greenfoot

2022/11/22

#
I made a small game. I hope it can refresh another wave of enemies after one wave of enemies is eliminated, but I don't know how to detect whether the first wave of enemies is eliminated. I hope some kind people can help me.
danpost danpost

2022/11/23

#
Logic_Greenfoot wrote...
I made a small game. I hope it can refresh another wave of enemies after one wave of enemies is eliminated, but I don't know how to detect whether the first wave of enemies is eliminated. I hope some kind people can help me.
Have act method of your world check for their non-existence:
if (getObjects(Enemy.class).isEmpty())
Logic_Greenfoot Logic_Greenfoot

2022/11/23

#
danpost wrote...
Logic_Greenfoot wrote...
I made a small game. I hope it can refresh another wave of enemies after one wave of enemies is eliminated, but I don't know how to detect whether the first wave of enemies is eliminated. I hope some kind people can help me.
Have act method of your world check for their non-existence:
if (getObjects(Enemy.class).isEmpty())
omg, it works.My teacher doesn't know this at all. Thank you for your help
You need to login to post a reply.