Hi, there!
So … I’m creating my main menu right now. I build most so far. But for some reason my if the loop doesn’t work. I want to achieve that my background music is only played when the user is in the world “MainMenu” if he pastes enter it should stop.
Here’s my code:
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1920, 1080, 1);
GreenfootImage bg = new GreenfootImage("london-background.png");
bg.scale(getWidth(), getHeight());
setBackground(bg);
mainMenu();
}
private void mainMenu() {
Logo logo = new Logo();
addObject(logo, 960, 540);
}
private void startMusic() {
background.playLoop();
}
private void stopMusic() {
background.stop();
}
private void backgroundMusic() {
if (World.MainMenu = true) {
startMusic();
} else {
stopMusic();
}
}
public void act() {
if(Greenfoot.isKeyDown("enter")) {
Greenfoot.playSound("mouse-click.mp3");
Greenfoot.setWorld(new playQuiz());
}
}
