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

2020/1/13

How to use set location to change between multiple worlds

Tietie12 Tietie12

2020/1/13

#
i have a platforming game where i have a start and goal actor class which are just used for detecting when the player reaches the end and to spawn the player at the start of the level.
  public void hitGoal()
    {
        Actor Goal = this.getOneIntersectingObject(Goal.class);
        if (Goal !=null && numLevel == 1)
        {
            Greenfoot.setWorld(new Level2());
           

        }
        
    }
i only know how to change from the first world and to the second but i would like to change to a third world when i hit the goal in the second level
danpost danpost

2020/1/13

#
Tietie12 wrote...
i have a platforming game where i have a start and goal actor class which are just used for detecting when the player reaches the end and to spawn the player at the start of the level. << Code Omitted >> i only know how to change from the first world and to the second but i would like to change to a third world when i hit the goal in the second level
Just determine the level and change worlds depending on that. For example:
if (getWorld() instanceof Level1)
Tietie12 Tietie12

2020/1/14

#
thank you so much it works perfectly
You need to login to post a reply.