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

2022/10/28

Multiple Worlds

RandomStudent29 RandomStudent29

2022/10/28

#
im trying to make a puzzle game at school but i dont know how do change the different levels i created my try to do this was:
if (anzahlDiamant == 0) {
            if(anzahlPushy == 0) {
              PushyGewinnt pushyGewinnt = new PushyGewinnt();
              addObject(pushyGewinnt, 9,7);
              Welt2 welt2 = new Welt2();
              Greenfoot.setWorld(welt2);
            }
        }
but it doesnt work For Context it is in my game ending code so instead of having Greenfoot.stop i tried Greenfoot.setWorld(welt2)
danpost danpost

2022/10/28

#
RandomStudent29 wrote...
im trying to make a puzzle game at school but i dont know how do change the different levels i created my try to do this was: << Code Omitted >> but it doesnt work For Context it is in my game ending code so instead of having Greenfoot.stop i tried Greenfoot.setWorld(welt2)
The code can be simply stated as the following:
if (anzahlDiamant == 0 && anzahlPushy == 0) Greenfoot.setWorld(new Welt2());
There is no reason to add an object into a world that is being dismissed by setting a new world. Both variables, anzahlDiamant and anzahlPushy, would have to be zero at the same time for the new world to start (provided the code is placed properly within your class).
You need to login to post a reply.