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);


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

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;
}


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

最佳答案

我认为您还需要描述皮肤如何渲染每个对象。您可以使用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>
        }
    }
}


希望这会有所帮助!

路易

关于java - 我的LibGDX皮肤类有问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17263617/

10-13 07:01