2
\$\begingroup\$

I have a texture atlas that is linked to my skin.json file. The atlas contains a region named "game-title".
I would like to declare a com.badlogic.gdx.graphics.Texture object in the json file, to retrieve it later in my code via skin.get(name, Texture.class).
I tried declaring it as follows, but it does not work - exception gets thrown - com.badlogic.gdx.utils.SerializationException: Class cannot be created (missing no-arg constructor): com.badlogic.gdx.graphics.Texture:

"com.badlogic.gdx.graphics.Texture": {
  "game-title": {name: "game-title"}
}  

What am I doing wrong here? What would be the correct way to do this? Is trying to declare a Texture in such a way a correct thing to do, in the first place?

Many thanks in advance for your feedback.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

All of the atlas regions are automatically available through the skin as TextureRegions. I just tried it, and works without modifying the json file.

You can just call skin.get(name, TextureRegion.class); or skin.getRegion(name);

Unfortunately, the skin docs are not very clear about this. libGdx docs

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .