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

2017/1/19

how to ask if the player wants a new game to be started

beyondFrustrated beyondFrustrated

2017/1/19

#
right now thats all i have
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;

public class Win extends Actor
{
    private int score;
    private String input ("yes");
    private  String input ("no");
    public Win () {
        setImage(new GreenfootImage("YOU WON! " + score + " score " + " . ", 35, Color.WHITE, Color.BLACK));
        Greenfoot.playSound("hooray.wav");  
    }
    public void act() 
    {
        newGame();
    }  
    public void newGame() {
        String input = Greenfoot.ask("New Game?");
         if (input = "yes") {
            addObject(new Star());
            Greenfoot.setWorld(new Spielfeld());
        }
           
    }
}
Super_Hippo Super_Hippo

2017/1/19

#
Change line 19 to:
if ("yes".equals(input))
Remove lines 7, 8 and 20.
beyondFrustrated beyondFrustrated

2017/1/19

#
thanks
You need to login to post a reply.