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

2017/5/27

Counter to 9 To change a new world

GrowlerGaming GrowlerGaming

2017/5/27

#
Hi, I'm new to Greenfoot. I am trying to set my code up so that when all _Goldballs are gone that It sends the user to Level02. I have tried to do this with my counter.
public void act()
    {
      if (Counter== 9)
      Greenfoot.setWorld(new Level02());
    }
I am writing this code in Level01 subclass, so that I can change the amount every level. Also I don't know what the variable (Counter) would be. Thanks
danpost danpost

2017/5/27

#
GrowlerGaming wrote...
I am trying to set my code up so that when all _Goldballs are gone that It sends the user to Level02.
I am not sure what 'Counter' would be, either. But, it sounds like all you need is the following for line 3
if (getObjects(Goldball.class).isEmpty())
You need to login to post a reply.