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

2014/12/15

Problems with Greenfoot.delay()

1
2
danpost danpost

2014/12/17

#
The only thing I can think that might work is to add the following method:
private void markAction()
    {
    int mark = (int)(System.currentTimeMillis()/600);
    while (mark == (int)(System.currentTimeMillis()/600));
    getWorld().repaint();
}
and place a call to it before every 'step' and 'turn' call.
cpothmann cpothmann

2015/1/11

#
I think I found a workaround for delay() not working right after the Scenario creation. The key is that Greenfoot.delay() will work after you've pushed the Act-Button once. So: - Put your algorithm into some method, e.g. "findOutOfLabyrinth()", including delays after each movement - Put nothing into the act()-methods of your actors - After compiling, build your scenario - Push the act-Button once (which will do nothing) - Then, the "findOutOfLabyrinth()"-method should work with delays.
olenz olenz

2015/1/11

#
Indeed, that seems to work! Nice workaround, thanks!
You need to login to post a reply.
1
2