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

2019/10/5

My code doesn't move to the actual minigame from the title screen

sjyang24 sjyang24

2019/10/5

#
import javax.swing.JOptionPane;
public class WelcomeText extends Actor
{
    /**
     * Act - do whatever the WelcomeText wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        String longString = "Welcome to Highway Traffic (Ver. Mandarin)"
        + System.getProperty("line.separator")+"click here to play";
        setImage(new GreenfootImage( longString, 30, Color.YELLOW, Color.PINK));
        
    if (Greenfoot.mouseClicked(this)){
            String inputValue = JOptionPane.showInputDialog("Enter name.. ");
            LevOne lev = new LevOne();
            Greenfoot.setWorld(lev);
    }   
      

} 
}
It is supposed to click the WecomeText, then write the my name, then it will move to the world "LevOne", however my game doesn't move to the actual minigame ("LevOne"). After few moment, I should click the Terminate Execution button to reset.
danpost danpost

2019/10/5

#
I am surprised that it compiles at all, as you do not seem to be importing greenfoot.* at all.
You need to login to post a reply.