本文介绍了不能正确使用LWJGL,代码给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行用于查看事件是否正确设置的代码:

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);
        }
    }
}

我已经完成了我一次又一次地检查了本地人,我非常确定我已经做到了,当我去这个项目的构建路径的图书馆,JRE系统库和Slick2D都说本地库的位置:.. ./windows/x64。我试过只是... / windows,我已经尝试了JRE没有本机的位置,我遵循两个不同的教程,如何做到这一点,我不断收到错误尝试运行这个简单的代码。任何帮助?

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构建路径>>打开库选项卡>>扩展JRE系统库>>点击本地库位置>>编辑>>外部文件夹>>找到..\lwjgl-2.9.0\\\
ative\windows文件夹在你的硬盘上>>选择它,你是完成

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);

我将这个字符串移动到其他位置,因为它显示在FPS计数器上:)

I would just move this string to some other location, cause it's showing over the FPS counter :)

编辑:

你可以使用.. \slick\lib\\\
atives-windows .jar。

you can use the natives from ..\slick\lib\natives-windows.jar.

使用WinRAR或其他东西打开它,并将其解压缩到一个文件夹,然后将该文件夹设置为您的Native库位置

open it with WinRAR or something and extract to a folder, then just set that folder to be your Native library location

这篇关于不能正确使用LWJGL,代码给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:41