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

2011/12/21

GAME OVER, YOU WIN, YOU LOSE

syakira syakira

2011/12/21

#
how to make coding that display each of that after game.
msnerdsays msnerdsays

2011/12/21

#
kelly!!!! ^^
Duta Duta

2011/12/23

#
I won't give you the whole code, because that's up to you (I don't know how you want it to look), but basically just have an actor that is created when you win/lose. You should have a parameter in the actor's constructor that says whether they won or lost. The actor should either have a constructor that makes a GreenfootImage which is then set as the actors image, like below:
public <actor name>(boolean hasWon)
{
    GreenfootImage img = new GreenfootImage(<(int) width>, <(int) height>);
    //Put whatever commands in here to change the image into how you want to look (see [url=http://www.greenfoot.org/files/javadoc/greenfoot/GreenfootImage.html]here[/url] for the javadoc if you don't know the methods)
    setImage(img);
}
Alternatively, you could create the images yourself in whatever image program you use, and have a constructor along the lines of:
public <actor name>(boolean hasWon)
{
    if(hasWon)
    {
        setImage("Won.png"); //Change the "Won.png" to whatever the name of your winning image is
    }
    else //They've lost
    {
        setImage("Lost.png"); //Obviously the same is true here as for the "Won.png"
    }
}
You need to login to post a reply.