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

2015/1/7

How do you create a timer in a greenfoot world or actor class?

PalmTree PalmTree

2015/1/7

#
Hi, I've tried to make an incrementing timer and vice versa. But none of them worked and I've referred to many posts on the website. I'm trying to make a timer that when it hits a certain number it will spawn an object in a world class but it would be helpful if it worked in the actor class aswell. thanks
danpost danpost

2015/1/7

#
A timer will work in either type of class (World or Actor). Just do not try to spawn (or create) actors from its own class. If you do, then if none of that type actor are in the world to begin with, none will ever spawn; and if one is in the world and one produces another, then both produce one more each, then... , the population of that type actor will increase exponentially. Your World subclass is the logical place to spawn objects into the world. You say you tried, but you did not show what you tried; so, it would be difficult to assist you with you code.
You need to login to post a reply.