这些线路对他们的错误bs.show
和g.dispose
有错误语法错误标识符想到这个令牌和部分g.drawImage
后说,删除标记和此令牌后decleratorid预计语法错误 说,说我做了什么错谁能帮助解决我的代码
g.drawImage(img, 0, 0, WIDTH HEIGHT, null);
g.dispose();
bs.show();
下面是完整的代码
package com.mime.WorldExplorer;
public static final int WIDTH = 800;
public static final int HEIGHT = 600;
public static final String TITLE = "World explorer(Name not final) Pre-Alpha 0.0.1";
private static final String createBufferStrategy = null;
private Thread thread;
private BufferedImage img;
private boolean running = false;
private Render render;
private Screen screen;
private int[]pixels;
private int i;
private BufferStrategy bs;
public Display() {
screen = new Screen(HEIGHT, WIDTH);
img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
pixels = ((DataBufferedInt)img.getRaster().getDataBuffer()).getData;
}
private void start() {
if (running)
return;
running = true;
thread = new Thread(this); }
private void stop() {
if(running)
return;
running = false;
try {
thread.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
public void run() {
while(running);
tick();
render();
}
private void render() {
BufferStrategy bs = this.getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
for (int i = 0; i<(WIDTH*HEIGHT); i++);
pixels[i] = screen.pixels[i];
}
Graphics g = bs.getDrawGraphics();
g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
g.dispose();
bs.show();
private void tick() {
}
public static void main(String[] args) {
Display game = new Display();
JFrame frame = new JFrame();
frame.add(game);
frame.pack();
frame.setTitle(TITLE);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.setResizable(true);
frame.setVisible(true);
System.out.println("Running....");
System.out.println("Working!");
game.start();
}
}
请 - 尝试并在您的问题中键入一些适当的英语。我不知道什么是错误信息,什么是问题。 – 2014-01-08 01:48:23
第一步将修复您的缩进。你的代码现在很难阅读。另外,请发布您收到的任何编译器错误的完整文本,并指出每个引用的哪一行。 –
没有办法完整的源代码,没有类声明... – MadProgrammer