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

2015/1/30

Why won't this thing spawn!?

DoctorMitch DoctorMitch

2015/1/30

#
So, I'm making my world, where the player controls the object "Cube". In the code I am making, the world wipes itself clean, then it SHOULD replace the object known as Cube. This is the code.
// Here's where we clear the board
getWorld().removeObjects(getWorld().getObjects(All.class));
//Here's where we're supposed to imput Cube
           nextLevel();



public void nextLevel() {
        World world = getWorld(); // gets the current world
        Cube newcube = new Cube(counter);
        world.addObject(newcube, 459, 305);
}
help would be greatly appreciated
Super_Hippo Super_Hippo

2015/1/30

#
Is the class in which 'nextLevel' is executed a subclass of 'All'? If yes, this won't work. Try to place the 'nextLevel' method into the world subclass then. If not, did you set an image to the Cube class? Do you have any error messages?
DoctorMitch DoctorMitch

2015/2/6

#
Thank you for your concern, but I made it work so that instead of the cube class deleting itself and replacing itself in a spawn point, it would just stay where it was, and things would spawn around it. When I upload the game, feel free to see for yourself.
You need to login to post a reply.