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

2014/6/22

Image Color

Hutanoi Hutanoi

2014/6/22

#
Hey men, i want to create an image which tells the actual score of my game. The creation works, but my background is black and the letters are also black, so one cant see it. Therefore i want to change the letters color. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; public class Anzeige extends Actor { public Anzeige(String text) { GreenfootImage Anz = new GreenfootImage (text.length()*20, 30); Anz.drawString (text, 2, 20); Anz.setColor(Color.YELLOW); setImage (Anz); } public void setText(String text) { GreenfootImage Anz = getImage(); Anz.clear(); Anz.drawString (text, 2, 20); } } The syntax doesnt have an error, but the letters color doesnt change. Any ideas? Thank you
Hutanoi Hutanoi

2014/6/22

#
ah, okay now it works :)
davmac davmac

2014/6/22

#
Please use 'code' tags when you post code. You have a method 'setText', but I don't see you calling it anywhere?
danpost danpost

2014/6/22

#
You need to set the drawing color BEFORE drawing the String text on the image.
You need to login to post a reply.