I am trying to display text on the screen and eclipse is telling me that the drawString method does not accept a Color variable. This is my code
import java.awt.Color;
import java.awt.Font;
import org.newdawn.slick.TrueTypeFont;
public class Text {
static TrueTypeFont font;
public static void drawText(int x, int y, String text) {
Font awtFont = new Font("Terminal", Font.BOLD, 24);
font = new TrueTypeFont(awtFont, false);
font.drawString(x, y, text, Color.yellow); //x, y, string to draw, color
}
}
And this is how I call the method.
Text.drawText(10, 10, "randomText");
It is saying that I am not allowed to put Color.yellow, can anyone please tell me what I am doing wrong. This is the error that I get if I try to run it with the color. Note that if I take away the Color it does draw it on the screen.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method drawString(float, float, String, Color) in the type TrueTypeFont
is not applicable for the arguments (int, int, String, Color)
Also if anyone could give an example of how to make a method that takes an z, y, String, and a Color that would help me a lot.
You will either have to change your import to
import org.newdawn.slick.Color
or usefont.drawString(x, y, text, org.newdawn.slick.Color.yellow);