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

2015/7/9

Help with Transfer to next level

BOBORING BOBORING

2015/7/9

#
i have a functional level 1 (Temple) in the game and transferring the character into the second level also works. The problem is my character wont move in the second level because the game crashes instantly. I believe its because the code for Player is always resetting something from Temple which shouldn't. Here is the code for the Player:
public void checkDoor()
    {
       if (level ==1)
       {
        Temple world = (Temple) getWorld();
        Counter counter = world.getCounter();
          if (getOneObjectAtOffset(0,0,Door.class)!= null && counter.getKeys()>0)
          {
            level =2;
            Greenfoot.setWorld(new Temple2());
            counter.removeKey();
          }
       }
       
    }
This is the part of the transfer code. When add an "if" statement to check the level the Player is in (I might have done it wrong). I also have to transfer a counter as you can see above. Please help me its for very soon.
You need to login to post a reply.