2
\$\begingroup\$

I want to create a list of buttons with ScrollPane , but I cant create a ScrollPane . In the constructor method in the examples Skins are used (.atlas , .json files) but how to create these files?

Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

Is there a program to generate this json ? As I noticed a lot of Scene2D elements need skins.

\$\endgroup\$
1
\$\begingroup\$

Unfortunately, you usually have to write these json files by hand. The syntax isn't too awful. To style an object its usually

<fullyQualifiedUIWidgetName>$<StyleClassName>:{
   <styleName>: {
       <styleParameter>: <value>,
       <styleParameter>: <value>,
   },
   <styleName>: {
       <styleParameter>: <value>,
       <styleParameter>: <value>,
   },
   ...
}

The libgdx test project has an example ui skin that I usually use to start from (just make sure that you copy the uiskin.atlas and uiskin.png files from the same directory to make it work)

Here is a pretty good article on using libgdx skins

Libgdx does, however, come with an atlas file generator called TexturePacker to help create your .atlas files from your image assets. You have to have inlcuded the tools library when you created your project.

It will take several different images and combine them into one or more pngs, then give you an atlas file. As long as this png and atlas file are in the same directory as the json file with the same name, then the skin will automatically load them

TexturePacker is a command line tool so I usually create another project to manage it. Here is a blog post I wrote on how to do that.

\$\endgroup\$
0
\$\begingroup\$

you can create scrollPane without that. Create it with no input and then call setWidget(Table or Actor) on it to attach the widget you want

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