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

2016/3/4

How can i create a multiple level in 1 world?

fearDnine fearDnine

2016/3/4

#
Hi,i want to make a Sokoban game.I want to make it with multipke level,but just in 1 world,so when the player reaches the door,all object in first level removed and replaced by all object in second level.Pkease help me T.T ..
Super_Hippo Super_Hippo

2016/3/4

#
It could look this this:
private int level = 1;

public WorldName()
{
    super(x,y,cs); //your values
    prepare();
}

public void prepare()
{
    switch(level)
    {
        case 1:
        //add all objects for level 1
        break;
        
        case 2:
        //add all objects for level 2
        break;
        
        //and so on
    }
}

public void nextLevel()
{
    removeObjects(null); //remove all objects from the world
    level++;
    prepare();
}
//in Player class
if (isTouching(Door.class))
{
    ((WorldName)getWorld()).nextLevel();
}
fearDnine fearDnine

2016/3/4

#
ah thankyou!!! it's work on my project :)
You need to login to post a reply.