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

2015/11/23

How do you correctly use Greenfoot.stop()?

Lamoose Lamoose

2015/11/23

#
Apologies for posting again so soon, but I am now wondering how do you most effectively end a Project with the Greenfoot.stop() function? I have a moving object that when colliding with an obstacle is supposed to stop all movement and accept no further inputs from pressed keys, as you would expect. But the only way I've managed to achieve this is by adding the stop function onto the end of each and every keyPress act, which produces the desired result but I feel is perhaps unnecessary. Is there no way I can have a single act on its own that ends everything? For instance, I tried simply using this for when the obstacle is detected:
private void stop()
    {
       if (barrier_detector()==true)
         {
             Greenfoot.stop();
         }
    }
but it does nothing? Thank you
You need to login to post a reply.