简体   繁体   中英

AssetManager libgdx

i'm trying to make a loading page for my game. my code its like this:

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

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

in a update function i have this:

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

what is setTexture function ? i get all textures from manager.

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

and i get this error:

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

line 31 is game.setTexture(manager) , and i get this eror before entering in the function because System.out.println("entered here"); is not appearing in console.

what i've done wrong ?

哦.. ty Noone,就是这样,游戏没有被宣布..因为应该是this.game = new Game(level),didint考虑了一下...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM