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

2013/6/5

Can someone help me?

Chocomint1213 Chocomint1213

2013/6/5

#
I am trying to make a game over screen for my crab game. I am also trying to make a winning screen. Can someone tell me how to build these?
uanimal uanimal

2013/6/6

#
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) import java.awt.Color; import java.awt.Font; import java.util.Calendar; /** * The ScoreBoard is used to display results on the screen. It can display some * text and several numbers. * * @author M Kolling * @version 1.0 */ public class GameOver extends Actor { public static final float FONT_SIZE = 48.0f; public static final int WIDTH = 600; public static final int HEIGHT = 300; /** * Create a score board with dummy result for testing. */ public GameOver() { this(100); } /** * Create a score board for the final result. */ public GameOver(int score) { makeImage("Game Over", "Game Score: ", score); } public void GameOver(int score) { makeImage("Game Over", "Game Score: ", score); } /** * Make the score board image. */ private void makeImage(String title, String prefix, int score) { GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT); image.setColor(new Color(255,255,255, 128)); image.fillRect(0, 0, WIDTH, HEIGHT); image.setColor(new Color(0, 0, 0, 128)); image.fillRect(5, 5, WIDTH-10, HEIGHT-10); Font font = image.getFont(); font = font.deriveFont(FONT_SIZE); image.setFont(font); image.setColor(Color.WHITE); image.drawString(title, 60, 100); image.drawString(prefix + score, 60, 200); setImage(image); } } with this example you can display the score
You need to login to post a reply.