目前我正在与LWJGL合作。我已经开始实现主菜单屏幕,虽然我有一个问题。
目前按钮只是呈现为两个三角形的四边形。 我知道我犯的是新手。
编辑:对不起,我忘了说按钮没有显示在任何地方。
以下是相关代码:
游戏:
if(state == GameState.MAIN_MENU){
Graphics.doMainMenuGraphics();
}
图形:
public static void doMainMenuGraphics(){
GL11.glClearColor(255, 255, 255, 0);
Setup.updateGraphics(GL_TRIANGLES);
glEnd();
menubutton.draw(); //Type is Button
}
按钮:
//Only relevant code
@Override
public void draw() {
if(hover){
GL11.glBegin(GL11.GL_TRIANGLES);
GL11.glColor3ub((byte) 0, (byte) 50, (byte) 205);
GL11.glVertex2f(x-20, y-5);
GL11.glVertex2f(x-20, y+5);
GL11.glVertex2f(x+20, y+5);
GL11.glVertex2f(x-20, y-5);
GL11.glVertex2f(x+20, y-5);
GL11.glVertex2f(x+20, y+5);
GL11.glEnd();
}else{
GL11.glBegin(GL11.GL_TRIANGLES);
GL11.glColor3ub((byte) 150, (byte) 150, (byte) 155);
GL11.glVertex2f(x-20, y-5);
GL11.glVertex2f(x-20, y+5);
GL11.glVertex2f(x+20, y+5);
GL11.glVertex2f(x-20, y-5);
GL11.glVertex2f(x+20, y-5);
GL11.glVertex2f(x+20, y+5);
GL11.glEnd();
}
GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
}
@Override
public void update() {
if(Mouse.getX() < x + 20 && Mouse.getX() > x - 20){
if(Mouse.getY() < y + 5 && Mouse.getY() > y - 5){
hover = true;
}
}
}
提前致谢,Curlip。