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

2014/12/16

Help with putting a simple line of text into my world?

Bluephoenix14 Bluephoenix14

2014/12/16

#
I've been working on a project in Greenfoot and need to have a statement show up saying "Infection Eradicated" when you win the game, or "Infection Uncontrollable" when the player loses. I've been looking for a simple batch of code to do this, but cannot find anything that will work properly. Could anyone help me? Note: I am adding comments to code that I didn't make on my own, so I'll give credit. Here's what I have so far: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; import java.awt.Font; public class Message extends Actor { public void Message() { update Image("Infection Eradicated"); <-----I keep getting an error in this line indicating that there needs to be a semicolon inserted right before ("Infection..) } public Message(String text) { updateImage(text); } public void setText(String text) { updateImage(text); } private void updateImage(String text) { setImage(new GreenfootImage(text, 30, Color.black, Color.white)); } I know there's most certainly going to be other errors, but I'd like any help or tips. Thank you guys.
danpost danpost

2014/12/16

#
Remove the space between 'update' and 'Image' on that line.
Bluephoenix14 Bluephoenix14

2014/12/16

#
Thank you Danpost! Everything compiled correctly!
You need to login to post a reply.