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

2012/9/17

Scoreboard help

Stephon231 Stephon231

2012/9/17

#
how do i make a score board show how leavesEaten.
danpost danpost

2012/9/17

#
Are you wanting a final scoreboard? or a score counter that starts at zero and increments as leaves are eaten?
Stephon231 Stephon231

2012/9/17

#
Finial Scoreboard
danpost danpost

2012/9/17

#
A really simple game over scoreboard would be as follows:
import greenfoot.*;
import java.awt.Color;

public class Scoreboard extends Actor
{
    public Scoreboard(int score)
    {
        setImage(new GreenfootImage("  GAME OVER  \n  Score: " + score + "  ", 96, Color.white, Color.darkGray));
    }

    public void act()
    {
        Greenfoot.stop();
    }
}
The only thing you need to do is, when you determine game over in your 'Wombat' class, add these lines
getWorld().addObject(new Scoreboard(leavesEaten), getWorld().getWidth() / 2, getWorld().getHeight() / 2);
return;
If you have problems trying to fit it into your Wombat class, post back with the code in question.
Stephon231 Stephon231

2012/9/27

#
96, Color.white, Color.darkGray)); it says that it can't find variable Color
Stephon231 Stephon231

2012/9/27

#
never mind found it
You need to login to post a reply.