1
我想在屏幕上显示文本,并且eclipse告诉我drawString方法不接受Color变量。这是我的代码LWJGL在屏幕上绘制彩色文本问题
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
}
}
这就是我所说的方法。
Text.drawText(10, 10, "randomText");
这是说我不允许放Color.yellow,任何人都可以告诉我我做错了什么。如果我尝试使用颜色运行它,这是我得到的错误。请注意,如果我拿走Color,它会在屏幕上绘制它。
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)
此外,如果任何人都可以给如何使接受一个Z,Y,字符串的方法,以及一种颜色,会帮我很多的例子。
油滑的2D有它自己的颜色类,你应该使用。 [Javadoc中](http://slick.ninjacave.com/javadoc/org/newdawn/slick/Color.html) – Cheloide