我正在尝试运行此代码,用于查看是否正确设置了内容:
package simpleslickgame; import java.util.logging.Level; import java.util.logging.Logger; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class SimpleSlickGame extends BasicGame { public SimpleSlickGame(String gamename) { super(gamename); } @Override public void init(GameContainer gc) throws SlickException {} @Override public void update(GameContainer gc, int i) throws SlickException {} @Override public void render(GameContainer gc, Graphics g) throws SlickException { g.drawString("Howdy!", 10, 10); } public static void main(String[] args) { try { AppGameContainer appgc; appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game")); appgc.setDisplayMode(640, 480, false); appgc.start(); } catch (SlickException ex) { Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex); } } }我所做的所有谷歌搜索都让我一遍又一遍地检查本地人,我很确定我做得对。当我去这个项目的构建路径中的库时,JRE系统库和Slick2D都说原生图书馆的位置:... / windows / x64。我只是尝试了... / windows,我尝试过没有原生位置的JRE。我按照两个不同的教程来说明如何做到这一点我尝试运行这个简单的代码时不断出错。有什么帮助吗?
I'm trying to run this code that is used to see if things were setup properly:
package simpleslickgame; import java.util.logging.Level; import java.util.logging.Logger; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class SimpleSlickGame extends BasicGame { public SimpleSlickGame(String gamename) { super(gamename); } @Override public void init(GameContainer gc) throws SlickException {} @Override public void update(GameContainer gc, int i) throws SlickException {} @Override public void render(GameContainer gc, Graphics g) throws SlickException { g.drawString("Howdy!", 10, 10); } public static void main(String[] args) { try { AppGameContainer appgc; appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game")); appgc.setDisplayMode(640, 480, false); appgc.start(); } catch (SlickException ex) { Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex); } } }All of the Googling I've done has led me to checking the natives over and over and I"m pretty sure I've done it right. When I go to the libraries in this project's build path, JRE System library and Slick2D both say Native library location: .../windows/x64. I've tried just .../windows, and I've tried it with the JRE not having a native location. I followed two different tutorials on how to do this and I keep getting errors trying to run this simple code. Any help?
最满意答案
基本上你需要的是将slick.jar和lwjgl.jar添加到你的构建路径,然后右键单击你的项目>>打开属性>>点击Java Build Path >>打开Libraries选项卡>>展开JRE系统库>>点击Native库位置>>编辑>>外部文件夹>>在硬盘上找到.. \ lwjgl-2.9.0 \ native \ windows文件夹>>选择它>>你就完成了
g.drawString("Howdy!", 10, 10);我只是将这个字符串移动到其他位置,因为它显示在FPS计数器上:)
编辑:
你可以使用.. \ slick \ lib \ natives-windows.jar中的原生代码。
用WinRAR或其他东西打开它并解压缩到一个文件夹,然后将该文件夹设置为您的本机库位置
basically what you need is to add slick.jar and lwjgl.jar to your build path and then right click your project >> open properties >> click on Java Build Path >> open Libraries tab >> expand JRE System Library >> click Native library location >> edit >> External Folder >> find ..\lwjgl-2.9.0\native\windows folder on your hard drive >> select it >> and you're done
g.drawString("Howdy!", 10, 10);I would just move this string to some other location, cause it's showing over the FPS counter :)
EDIT:
you can use the natives from ..\slick\lib\natives-windows.jar.
open it with WinRAR or something and extract to a folder, then just set that folder to be your Native library location
更多推荐
发布评论