I'm making a 2D maze game and attempting to open a portal to a second level once 5 items have been collected from the maze. The portal to the next level works fine I just need to add it into the world after all 5 items have been collected.
This is what I have so far:
This gives me a nullPointerExceptionError and I can't figure out why.
Any help would be great! Cheers.
public class SpaceshipPart extends Actor { public static int spaceshipPart = 0; /** * Act - do whatever the SpaceshipPart wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { collectParts(); } public void collectParts() { Actor d = getOneIntersectingObject(Spaceman.class); if (d != null) { World MazeWorld = getWorld(); MazeWorld.removeObject(this); spaceshipPart++; } if(spaceshipPart == 5) { getWorld().addObject(new LEVEL1(), 986, 584); } } }