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

2013/12/4

Count code?

jennifer56 jennifer56

2013/12/4

#
I am new to Greenfoot (very new!). I have created a game where I collect parcels then exit to a second level, collect parcels again and go through to the final screen. However I can go through the exit at any time. I need help in getting a code that will only allow me through only if I have collected all the parcels. P.S. Could you, if possible, make the answer simple as my brain is frazzled!!! Thank you.
danpost danpost

2013/12/4

#
Just add an 'if' condition that prevent continuing on to the next level unless all parcels are gone:
if (getWorld().getObjects(Parcel.class).isEmpty())
Remove the 'getWorld().' part if coded in your subclass of world.
jennifer56 jennifer56

2013/12/4

#
Thank you. Today You are my HERO xxx
You need to login to post a reply.