2014-10-29 71 views
0

錯誤代碼:Slick2d主要計劃問題

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path 
at java.lang.ClassLoader.loadLibrary(Unknown Source) 
at java.lang.Runtime.loadLibrary0(Unknown Source) 
at java.lang.System.loadLibrary(Unknown Source) 
at org.lwjgl.Sys$1.run(Sys.java:73) 
at java.security.AccessController.doPrivileged(Native Method) 
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) 
at org.lwjgl.Sys.loadLibrary(Sys.java:95) 
at org.lwjgl.Sys.<clinit>(Sys.java:112) 
at org.lwjgl.opengl.Display.<clinit>(Display.java:135) 
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39) 
at java.security.AccessController.doPrivileged(Native Method) 
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36) 
at bossRush.MainGame.main(MainGame.java:41) 

主要代碼:

package bossRush; 

import org.newdawn.slick.AppGameContainer; 
import org.newdawn.slick.GameContainer; 
import org.newdawn.slick.SlickException; 
import org.newdawn.slick.state.StateBasedGame; 

public class MainGame extends StateBasedGame { 
public static final String name = "Boss Rush"; 
public static final int menu = 0; 
public static final int map = 1; 
//public static final int play = 2; 
//public static final int save = 3; 
//public static final int load = 4; 
//public static final int DIX = 5; 

public MainGame(String name) { 
    super(name); 
    this.addState(new Menu(menu)); 
    this.addState(new Map(map)); 
    //this.addState(new Play(play)); 
    //this.addState(new Save(save)); 
    //this.addState(new Save(load)); 
    //this.addState(new Menu(DIX)); 
} 


public void initStatesList(GameContainer gc) throws SlickException { 
    this.getState(menu); 
    this.getState(map); 
    //this.getState(play); 
    //this.getState(save); 
    //this.getState(load); 
    //this.getState(DIX); 
    this.enterState(menu); 
} 

public static void main(String[] args){ 
    AppGameContainer appgc; 
     try{ 
      appgc = new AppGameContainer(new MainGame(name)); 
      appgc.setDisplayMode(640, 640, false); 
      appgc.start(); 
     }catch(SlickException e){ 
      e.printStackTrace(); 
     } 
} 

} 

最後狀態的一個樣本:

package bossRush; 

import org.newdawn.slick.GameContainer; 
import org.newdawn.slick.Graphics; 
import org.newdawn.slick.SlickException; 
import org.newdawn.slick.state.BasicGameState; 
import org.newdawn.slick.state.StateBasedGame; 

public class Menu extends BasicGameState{ 
public static int ID; 

public Menu(int id){ 
    ID = id; 
} 

public void init(GameContainer arg0, StateBasedGame arg1)throws SlickException { 


} 

public void render(GameContainer arg0, StateBasedGame arg1, Graphics arg2)throws SlickException { 

} 

public void update(GameContainer arg0, StateBasedGame arg1, int arg2)throws SlickException { 

} 

public int getID() { 
    return ID; 
} 

} 

我不知道是什麼原因造成的錯誤,如果你有一個建議,請讓我知道。如果它與需要引用的內容有關,請使用slick.jar,lwjgl.jar,jinput.jar。

回答

0

您缺少lwjgl的庫文件。如果是Windows,它將是一個.dll文件,如果是Linux,它將是一個.so文件。

檢查lwjgl文檔以找出缺少的內容。

+0

我已經導入廣告,將本機設置爲窗口 – 2014-10-30 19:08:59

0

OMG我下載了錯誤的lwjgl。 我不得不重新下載以獲得正確的lwjgl以獲取正確的本地人。 給任何這樣做的人,你不能下載「lwjgl源文件」,只是「lwjgl」文件。