Here I have an Object. When the Object gets clicked, the world should change. But when I activate the title variable and setWorld(), the Scenario becomes unstable and loads forever.
Is there a way to fix this?
import lang.stride.*; import java.util.*; import greenfoot.*; /** * */ public class GoBack extends Actor { private boolean hasSoundPlayed = false; private GreenfootSound click = new GreenfootSound("buttonclick.wav"); /* private TitleScreen title = new TitleScreen();*/ /** * */ public void act() { HowToPlay htp = (HowToPlay)getWorld(); if (Greenfoot.mouseMoved(this)) { setImage("goback_bigger.png"); htp.hover.setVolume(75); if (this.hasSoundPlayed == false) { htp.hover.play(); this.hasSoundPlayed = true; } } if ( ! Greenfoot.mouseMoved(this) && Greenfoot.mouseMoved(null)) { this.hasSoundPlayed = false; setImage("goback.png"); } if (Greenfoot.mousePressed(this)) { this.click.setVolume(75); this.click.play(); /* Greenfoot.setWorld(title);*/ } } }