1
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: No com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle registered with name: default
at com.badlogic.gdx.scenes.scene2d.ui.Skin.get(Skin.java:138)
at com.badlogic.gdx.scenes.scene2d.ui.Skin.get(Skin.java:125)
at com.badlogic.gdx.scenes.scene2d.ui.TextField.<init>(TextField.java:114)
at com.mathieu.develop.DevelopController.createButtons(DevelopController.java:56)
at com.mathieu.develop.DevelopController.<init>(DevelopController.java:49)
at com.mathieu.view.GameScreen.show(GameScreen.java:55)
at com.badlogic.gdx.Game.setScreen(Game.java:62)
at com.mathieu.game.MainGame.create(MainGame.java:19)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:132)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:112)

当我尝试这样做时出现此错误:

Skin skin = new Skin(GS.textFieldAtlas);
objectTextFieldSetName = new TextField("Object", skin);

我正在尝试使用两个文件文件创建皮肤:

https://www.dropbox.com/s/85rlj4kjq95y3lv/textures.png https://www.dropbox.com/s/0az61wy2fbsmz8p/textures.pack

private TextureAtlas loadTexturePack() {
    try {
        return new TextureAtlas(Gdx.files.internal("images/textures.pack"));
    } catch(Exception ex) {
        System.out.println(ex);
    }
    return null;
}

我正在尝试制作一个文本字段,以便我可以输入。任何帮助将不胜感激!

4

1 回答 1

2

我认为您还需要描述皮肤如何渲染每个对象。您可以使用 JSON 文件或以编程方式执行此操作。在 wiki 中查看此页面:http ://code.google.com/p/libgdx/wiki/Skin#Skin_JSON

从上面页面上的 JSON 示例:

{
    com.badlogic.gdx.graphics.Color: {
        white: { r: 1, g: 1, b: 1, a: 1 },
        red: { r: 1, g: 0, b: 0, a: 1 },
        yellow: { r: 0.5, g: 0.5, b: 0, a: 1 },
    },
    com.badlogic.gdx.graphics.g2d.BitmapFont: {
        medium: { file: medium.fnt }
    },
    com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
        default: {
            down: round-down, up: round,
            font: medium, fontColor: white
            },
        toggle: {
            down: round-down, up: round, checked: round-down,
            font: medium, fontColor: white, checkedFontColor: red
        },
        green: {
            down: round-down, up: round,
            font: medium, fontColor: { r: 0, g: 1, b: 0, a: 1 }
        }
    }
}

皮肤正在寻找类似的东西。特别是在“默认”变量中定义的值。我会假设它看起来像这样:

{
    com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: {
        default: {
            <fields defined in TextFieldStyle>
        }
    }
}

希望这是一些帮助!

路易斯

于 2013-07-03T15:19:38.103 回答