Hi all,
I’m having some issues getting skins to load into my LibGDX program. I was able to get the default program to work that displays the badlogic.jpg image, but everything else I’ve tried to do using skins has been less successful.
I’m new to LibGDX and still learning, but from my understanding all images have to be placed under the Android project and I’ve tried placing files in the Android “assets” folder and I’ve also tried placing them in the “assets/data” folder (saw this mentioned on stackoverflow). In Eclipse I have pointed the desktop application to use the Android assets folder.
When trying to create a label using the uiskin the Android version gives an error on this line when trying to load the uiskin.json, however it does work on the desktop version.
skin = new Skin(Gdx.files.internal(“uiskin.json”));
The button.pack I created won’t load on either the desktop or the Android version.
skin2 = new Skin(Gdx.files.internal(“button.pack”));
As far as I can tell I have all the files that it needs to load these skins. For the uiskin I downloaded the 5 necessary files (default.fnt, default.png, uiskin.atlas, uiskin.json, and uiskin.png) and for the button I’ve gone through the steps of creating a 9-patch and then the button pack.
I haven’t been able to find anything that really spells out clearly where to put these files and how to load them in yet.
For example, the documentation for the Gdx.files.internal() method states:
“Convenience method that returns a Files.FileType.Internal file handle.”
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.html#internal-java.lang.String-
And for Files.FileType.Internal file handle:
“Path relative to the asset directory on Android and to the application’s root directory on the desktop. On the desktop, if the file is not found, then the classpath is checked. This enables files to be found when using JWS or applets. Internal files are always readonly.”
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Files.FileType.html#Internal
This states the path is relative to the “assets” folder, however when I tried putting the default uiskin in the “assets” folder it didn’t load for the desktop, but when I put it in the “assets/data” folder it did load. Android didn’t load at all, whether I had the files in “assets” or in “assets/data”. However, running the default program with the badlogic.jpg image did work with it placed in the “assets” folder for both desktop and Android.
I’ve looked at the documentation and other tutorials, but it’s not coming together just yet. Can anyone break down the process of loading skins a more than the existing documentation? I’d greatly appreciate it, thanks!