When pressing space in GameOver screen it instantly goes to MapSelect instant of going to Startscherm and then pressing space again to transition into mapselect. Help is appreciated im a studend doing this voor school.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Startscherm here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Startscherm extends World {
private GreenfootSound backgroundMuziek;
private GreenfootSound soundEffect;
public Startscherm() {
super(1280, 720, 1);
backgroundMuziek = new GreenfootSound("Brawling.mp3");
backgroundMuziek.playLoop();
soundEffect = new GreenfootSound("8bit Click Sound Effect.mp3");
}
public void act() {
if (Greenfoot.isKeyDown("space")) {
backgroundMuziek.stop();
soundEffect.play();
Greenfoot.setWorld(new MapSelect());
}
if (Greenfoot.isKeyDown("z")) {
backgroundMuziek.stop();
soundEffect.play();
Greenfoot.setWorld(new Uitleg());
}
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GameOverScherm here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GameOverScherm extends World
{
GifImage myGif = new GifImage("gameover.gif");
private GreenfootSound backgroundMusic;
/**
* Constructor for objects of class GameOverScherm.
*
*/
public GameOverScherm()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(480,360, 1);
backgroundMusic = new GreenfootSound("bonnie's lullaby.mp3");
backgroundMusic.playLoop();
}
public void act()
{
setBackground( myGif.getCurrentImage() );
if (Greenfoot.isKeyDown("space")) {
backgroundMusic.stop(); // Stop background music
Greenfoot.setWorld(new Startscherm());
}
}
}
