os ride


SUBMITTED BY: ajiamino

DATE: Feb. 2, 2016, 6:03 a.m.

FORMAT: Text only

SIZE: 904 Bytes

HITS: 3719

  1. import Greenfoot.*;
  2. import java.awt.Color;
  3. public class GameOver extends Actor
  4. {
  5. String msgTxt = "GAME OVER"
  6. public GameOver()
  7. {
  8. updateImage();
  9. }
  10. public GameOver(String txt)
  11. {
  12. msgTxt = txt;
  13. updateImage();
  14. }
  15. private void updateImage()
  16. {
  17. GreenfootImage image = new GreenfootImage(getWorld().getWidth(), getWorld().getHeight()); // or whatever size you want the object
  18. image.setColor(Color.cyan); // color of your choice
  19. image.fill();
  20. GreenfootImage txtImg = new GreenfootImage(msgTxt, 36, Color.black, new Color(0, 0, 0, 0)); // colors and font size of your choice
  21. image.drawImage(txtImg, (image.getWidth() - txtImg.getWidth()) / 2, (image.getHeight() - txtImg.getHeight) / 2);
  22. // whatever else you might want to do for the image
  23. setImage(image);
  24. }
  25. }

comments powered by Disqus