Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

How would you declare a Texture object in the libgdx skin json file, using a region from a texture atlas?

$
0
0

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.


Viewing all articles
Browse latest Browse all 434

Trending Articles