Question

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)

I get this error when i try doing this :

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

I am trying to create a skin with the two files 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;
}

I am trying to make a text field so i can type in. Any help would be appreciated!

Was it helpful?

Solution

I think you also need to describe how each object is rendered by the skin. You can do this with a JSON file or a programatically. See this page in the wiki: http://code.google.com/p/libgdx/wiki/Skin#Skin_JSON

From the JSON example on the page above:

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

The skin is looking for something similar. Specifically the values defined in the 'default' variable. I would assume it would look something like this:

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

Hope this is some help!

Louis

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top