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

2012/1/24

how can i make objects appear after x amount of time elaspes

craigv craigv

2012/1/24

#
I want it set up so that when my counter reaches a certain amount (set at 20 for testing purposes), new objects will start to appear appearing at random times at random positions along the left side of screen. counter++; if (counter == 20) { if (Greenfoot.getRandomNumber(200) <10) addObject(new pointBall2(), 0, Greenfoot.getRandomNumber(600)); // } /** *the code, without the counter ++, if( counter == 20){} works the way i want it too. essentially all * I want to add is a delay before the function takes place */
davmac davmac

2012/1/24

#
The problem is that you keep incrementing the counter after it reaches 20. How about:
if (counter == 20) {
    if (Greenfoot.getRandomNumber(200) <10)
        addObject(new pointBall2(), 0, Greenfoot.getRandomNumber(600));
}
else {
    counter++;
}
You need to login to post a reply.