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

2019/3/20

Code for Spawner

Brandon13 Brandon13

2019/3/20

#
I am trying to make my spawner spawn a certain number instead of unlimited spawing but unsure of the code
danpost danpost

2019/3/20

#
Brandon13 wrote...
I am trying to make my spawner spawn a certain number instead of unlimited spawing but unsure of the code
Add a counter field to count number spawned:
private int spawned;
Add the following line immediately after spawning:
if (++spawned == 10) getWorld().removeObject(this);
Adjust the limit (10) as needed.
You need to login to post a reply.