在 libgdx 上创建选择框时遇到问题。
Skin.add("button", new Texture("data/menu/button.png"));
[...]
SelectBoxStyle selectboxstyle = new SelectBoxStyle();
selectboxstyle.font = new BitmapFont(Gdx.files.internal("data/fonts/menufont.fnt"), Gdx.files.internal("data/fonts/menufont.png"), false);`
selectboxstyle.background = Skin.getDrawable("button");
SelectBox dropdown = new SelectBox(new String[] {"item1", "item2"}, selectboxstyle);
最后一行抛出异常:
com.badlogic.gdx.scenes.scene2d.ui.SelectBox.setItems(SelectBox.java:140) 的 com.badlogic.gdx.scenes.scene2d.ui.SelectBox 的线程“LWJGL 应用程序”java.lang.NullPointerException 中的异常。 (SelectBox.java:71) 在 com.me.Terminum.Screens.MainMenu.ShowVideo(MainMenu.java:171) 在 com.me.Terminum.Screens.MainMenu.show(MainMenu.java:121) 在 com.badlogic。 gdx.Game.setScreen(Game.java:62) at com.me.Terminum.Screens.SplashScreen.show(SplashScreen.java:88) at com.badlogic.gdx.Game.setScreen(Game.java:62) at com .me.Terminum.App.create(App.java:13) 在 com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136) 在 com.badlogic.gdx.backends.lwjgl.LwjglApplication$1。运行(LwjglApplication.java:114)
我在 libgdx 0.9.8 和 0.9.9 上检查了它。我做错了什么?