Hi!
I have a MenuWorld with a Button object in it. When you click on the Button object, it calls a method in this Button to go to a new CinematicWorld (which will then send you into a PlanetWorld). This works almost fine, because it does create a new CinematicWorld and setWorld()s to it. However, the game is paused in this new CinematicWorld. What's the matter here? (I checked and there are no crashes, no console opening. When I relaunch the game manually, it works fine.)
The startGame method in the Button class:
The CinematicWorld constructor:
Thank you very much for your help! :)
private void startGame(boolean started) {
if (!started)
{
// set all the variables
/** add this later if needed */
// create a new CinematicWorld with a random color
Color c = new Color(Greenfoot.getRandomNumber(55 + 125),
Greenfoot.getRandomNumber(55 + 125),
Greenfoot.getRandomNumber(55 + 125));
CinematicWorld cWorld = new CinematicWorld(0, c);
Greenfoot.setWorld(cWorld); // sends to an "arrive on planet" cinematic
System.out.println("Hi");
}
else // if there is a save file
{
/** read from text file and stuff */
}
} public CinematicWorld(int cinematicType, Color c) /** I might want to add a parameter for planet color here. Then call the PlanetWorld with
that color as a parameter, once the cinematic is finished */
{
// A. GENERAL IMAGE OF THE BACKGROUND:
super(600, 600, 1);
// initialize colors
themeColor = c;
themeColorD = c.darker();
// a1. DRAW THE SIMPLE BACKGROUND:
GreenfootImage background = new GreenfootImage(getWidth(), getHeight());
background.setColor(Color.BLACK);
background.fill();
// a2. DRAW STARS:
background.setColor(Color.WHITE); // color of the stars
int R = 3; // radius of the stars
// this "for" loop creates stars randomly
for (int i = 0; i < 300; i++){
background.fillOval(Greenfoot.getRandomNumber(getWidth()),
Greenfoot.getRandomNumber(getHeight()),
R,
R);
}
// a3. DRAW THE PLANET IN THE LOWER-LEFT CORNER:
int pR = 1000; // radius of the planet
GreenfootImage llPlanet = new GreenfootImage(pR, pR);
llPlanet.setColor(themeColor);
llPlanet.fillOval(0, 0, pR/2, pR/2);
/** add code to draw other ovals on the planet, for craters */
background.drawImage(llPlanet, getWidth()/2, getHeight()/2 - 150);
// a4. FINALLY SET THE BACKGROUND:
setBackground(background);
// B. ASSIGNMENTS:
cType = cinematicType;
// C. LAUNCH THE CINEMATIC:
cInit();
}

