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

2014/9/14

How do I stop a method from running

DarkSoulDemon DarkSoulDemon

2014/9/14

#
Thank you everyone who helps
NikZ NikZ

2014/9/14

#
The easy way is return, but it might cause problems.
NikZ NikZ

2014/9/14

#
Return is only code - you will not be able to stop a method while it's running with it.
DarkSoulDemon DarkSoulDemon

2014/9/14

#
so if I have this methodwhere would i put return
public void NextLevel2()
   {
      
        if (score == 20){
          Greenfoot.setWorld(new L3());
          //This code changes the back ground to level 3 when 20 points are scored 
         }  
   }
danpost danpost

2014/9/14

#
There is no need for a return in this method. In fact, I believe that any problem you may have been experiencing is probably resolved by the changes I gave in another discussion thread.
DarkSoulDemon DarkSoulDemon

2014/9/14

#
okay Thankyou i was not sure if it was the fact i kept calling the method and that is why it could never get past level2 Thank you very much to the people who helped
You need to login to post a reply.