How to use LIBGDX TexturePacker2?

940 views Asked by At

I'm having difficultly using the TexturePacker2 class... Could someone clarify what I'm doing wrong?

I have an input directory called basics, and an output directory called output.

This is my input directory:

This is my output after using the TexturePacker2 via source with my input directory, output directory, and "basics.pack" as parameters:

Then, I copied all the files in output and my old .tmx file into the assets/data/tiles folder into my libgdx project:

And finally, I try to load everything into my program with the following code, which also shows the error I'm getting at the bottom:

Two concerns I have:

1) Shouldn't using TexturePacker2 create an updated .tmx file in my output directory as well?

2) Why is my packfile not found (this is my main issue... -- it finds other files in the same directory perfectly fine).

A big thanks in advance!

1

There are 1 answers

1
bemeyer On BEST ANSWER

Your way is outdate for tmxFiles. There is no TiledAtlas anymore. In case you use an older version just use the regular TmxMapLoader without packing your grafics.

Here is a simple example how to load a Tilemap:

TmxMapLoader load = new TmxMapLoader();
TiledMap map = load.load("path/to/file");

You can even combine it with an Assetmanager:

assetmanager.setLoader(TiledMap.class, new TmxMapLoader(
            new InternalFileHandleResolver()));

Please take a look to the answer i made at this question to get more information about the texture stuf where it need to be and how you can change the filepath inside of the .tmx and so on:
tmxmaploader-to-use-packed-tileset