2013-10-19 6 views
0

내 게임의 로딩 페이지를 만들려고합니다. 내 코드는 다음과 같습니다 :AssetManager libgdx

if (manager.update()){ 
    game.setTexture(manager); 
} 

는 SetTexture 기능은 무엇인가 :이 가지고 업데이트 기능에

manager = new AssetManager(); 
game = new Game(level); 
game.startLoadingTextures(manager); 

public void startLoadingTextures(AssetManager manager){ 
    manager.load("data/background.png" ,Texture.class); 
} 

? 나는 매니저에게서 모든 짜임새를 얻는다.

public void setTexture(AssetManager manager) { 
    System.out.println("entered here"); 
    background = manager.get("data/background.png" ,Texture.class); 
} 

는 난이 오류 얻을 : 31 game.setTexture(manager)이다

Exception in thread "LWJGL Application" java.lang.NullPointerException 
at com.smeurares.game.Loading.update(Loading.java:31) 

라인, 그리고 콘솔 나타나지 않음 System.out.println("entered here"); 때문에 함수에 들어가기 전에이 eror을 얻는다.

나는 무엇을 잘못 했습니까?

+0

'game'이 있어야합니다 ... 그것에 대해 thinked '널'까지 31 행을 잡아라. 디버거를 사용하고 코드가 단계적으로 진행되면서 왜 '널'인지 알아 내라. – noone

답변

0

오 .. 타이 아무도, 그 것이었다 그, 게임은 .. 선언되지는 this.game = 새로운 게임 (레벨)을해야하기 때문에, didint는