我无法弄清楚这里有什么问题。我实例化我的对话框,但仍然收到NullPointerException。以下是相关代码:
Dialog window = new Dialog("Game Over", AssetLoader.uiSkin);
window.setWidth(136);
window.setHeight(gameHeight / 2);
window.setPosition(0, gameHeight / 4);
window.button(new TextButton("Play Again", AssetLoader.uiSkin));
window.draw(batcher, 1);
这是我的uiskin.json文件:
{
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: font/silkscreen.fnt } },
com.badlogic.gdx.graphics.Color: {
green: { a: 1, b: 0, g: 1, r: 0 },
white: { a: 1, b: 1, g: 1, r: 1 },
red: { a: 1, b: 0, g: 0, r: 1 },
black: { a: 1, b: 0, g: 0, r: 0 }
},
com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
default: { down: btnActive, up: btn },
toggle: { down: btnActive, checked: btnActive, up: btn }
},
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
default: { down: btnActive, up: btn, font: default-font, fontColor: white },
toggle: { down: btnActive, up: btn, checked: btnActive, font: default-font, fontColor: white, downFontColor: red }
},
com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle: {
default: { titleFont: default-font, background: btn, titleFontColor: white },
dialog: { titleFont: default-font, background: btn, titleFontColor: white }
}
}