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

2013/5/22

I want to create a win method after a certain number of actors are collected, anyone know how?

My world is a snake, a mouse, and a strawberry. The mouse tries to eat the strawberries without touching any of the snakes. I want to make a win segment after you gather five strawberries, I looked at other discussions and tried their code and couldn't get it to work. Help?
danpost danpost

2013/5/22

#
First, you need to be able to count the number of strawberries eaten. This is done by adding an instance int field to your mouse class to hold the value; and when a strawberry is eaten, increase its value and check to see if it is now five. If it is, either add the win segment actor to the world or set a new win segment world as active (depending on how you implement your win segment).
You need to login to post a reply.