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

2020/11/3

How to make a start button

willsumner willsumner

2020/11/3

#
I want to make a button so that when I click it, my game starts and the button goes away, and then when the game ends the button re-appears and restarts the game. Does anybody know how I can do this?
danpost danpost

2020/11/3

#
willsumner wrote...
I want to make a button so that when I click it, my game starts and the button goes away, and then when the game ends the button re-appears and restarts the game. Does anybody know how I can do this?
What kind of scenario is this for? Describe please. The best approach would be determined by this.
PascalFischer PascalFischer

2020/11/10

#
A button is basically just this Code:
    public void clickButton()
    {
        if(Greenfoot.mouseClicked(this))
        {
            Greenfoot.setWorld(new Level1());
            Greenfoot.playSound("ButtonSound.mp3");
        }
    }
You can make a new World, called startscreen or something like that, and make an Actor with this Code in it. Then make the button in your Start Screen, and it should work
You need to login to post a reply.