1
\$\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\$
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.