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

2013/11/12

next level

1
2
3
payner2013 payner2013

2013/11/12

#
is there anyway that i can go to the next level if my score reaches so much and carry that score through to the next level?
shrucis1 shrucis1

2013/11/12

#
Yes; it's a simple matter of subtracting a certain number from your current score and setting your new score to that.
payner2013 payner2013

2013/11/12

#
so do you know how i get to the next level from a peticular score?
shrucis1 shrucis1

2013/11/12

#
Well, you could do something inside an act loop, like this:
public void act()
{
   if(myScore>=scoreNeeded) {
      gotoNextLevel();
   }
   doStuff();
}
Where myScore is the variable that you use to keep the score (Or counter.getValue()) and scoreNeeded is the amount you need to advance to a particular level, and void gotoNextLevel() would take you to the next level. Does this answer your question?
payner2013 payner2013

2013/11/12

#
yes it does thank you. but in my case next level is a new world so could i do where it says gotoNextLevel(); can i use: Greenfoot.setWorld(new /* the new world *\());
shrucis1 shrucis1

2013/11/12

#
Yes, but make sure that the act function I described earlier is world-specific. Otherwise it might go from level 1 to 2, and then keep going to level 2. But yeah, that should work. Glad to help!
payner2013 payner2013

2013/11/12

#
yay im sort of getting the hang of this, thanks alot :)
payner2013 payner2013

2013/11/12

#
1 last thing, what class would this go in? the counter or the world?
danpost danpost

2013/11/12

#
You could look at my Level Changing Demos. Go to my page and then to my scenarios (click on 'Show all'). They should be on the first page there.
payner2013 payner2013

2013/11/12

#
ok thank you very much :)
payner2013 payner2013

2013/11/12

#
ok your way is confusing... i did it like this...
public void nextLevel()
    {
    if((Counter) >= 100)
         {  
      Greenfoot.setWorld(new Space2());
    }
  }
but as i though it didn't work. is there any way you can make it work? the error says 'cannot find symbol - variable counter...
danpost danpost

2013/11/12

#
In what class is the 'nextLevel' method located? and, again, for the value of the counter, you need to do similar to what was discussed in the other thread.
payner2013 payner2013

2013/11/13

#
 public void nextLevel()
    {
    if((Counter) >= 100)
         {  
      Greenfoot.setWorld(new Space1());
    }
its in my rocket and looks likie this...
danpost danpost

2013/11/13

#
danpost wrote...
for the value of the counter, you need to do similar to what was discussed in the other thread.
payner2013 payner2013

2013/11/13

#
but what part of that Discusion?
There are more replies on the next page.
1
2
3