好的我正在开发一款游戏,我正在努力解决为什么光滑的更新方法无法正常工作,基本上在我看到它工作的教程中,但在我看来它没有。我问你的管教程视频,没有人知道为什么会这样。所以任何帮助将不胜感激。这是我的代码:
package phex.launcher;
import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.opengl.*;
import org.lwjgl.*;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Phex extends BasicGameState{
public static int screen;
private Image tweet;
private Image logo;
private Image base;
private Graphics g;
private GameContainer gc;
public Phex() throws SlickException
{
new LoginButton();
try {
Display.setDisplayMode(new DisplayMode(800, 650));
Display.setTitle("Phex Launcher");
Display.setResizable(true);
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
System.exit(1);
}
init(gc, null);
//Initialisation code(OpenGL)
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Resets any previous projection matrices
glOrtho(0, 800, 650, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
while(!Display.isCloseRequested())
{
//render
render(gc, null, g);
update(gc, null, 0);
}
Display.destroy();
}
public static void main(String args[]) throws SlickException
{
new Phex();
}
public void init(GameContainer container, StateBasedGame game)
throws SlickException {
tweet = new Image("img/twitter-logo.png");
logo = new Image("img/logo.png");
base = new Image("img/base-for-login.png");
}
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
{
Display.destroy();
System.exit(0);
}
base.draw(0,0);
logo.draw(50, 5);
tweet.draw(200, 5);
//screen renderer
screen = 0;
if(screen == 0)
{
}
if(screen == 1)
{
}
Display.update();
Display.sync(60);
}
public void update(GameContainer container, StateBasedGame game, int delta)throws SlickException {
int posx = Mouse.getX();
int posy = Mouse.getY();
if((posx>50 && posx<150)&&(posy>5 && posy<100))
{
System.out.println("in area");
if(Mouse.isButtonDown(0))
{
Display.destroy();
}
}
}
@Override
public int getID() {
return 0;
}
}
答案 0 :(得分:1)
周六早餐时阅读这篇文章(即没有太多深度!)看起来你正在覆盖BasicGameState
,而不是StateBasedGame
。我无法在任何地方看到任何证据?