Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX - Packing Tile maps (.tmx) for use in code  (Read 10887 times)
0 Members and 1 Guest are viewing this topic.
Offline vbrain
« Posted 2013-02-14 04:00:45 »

The LibGDX wiki on this topic is quite confusing and may be hard to understand.

I will assume you have already created your map in Tiled and saved it (.tmx) and your tileset images in a folder.

Save location of your original (.tmx) map and resources:
We'll call this "resources\images"

In that folder we have the .tmx map file, the mapterrain.png (the tileset used in the Tiled application), and a .bat file called "map_command.bat" which we will go into later.

Now let's go into our game project's asset folder:
Be sure you are in the "-android" folder!

Create a NEW folder called "maps" in the assets folder. This is important because when we pack the map file, the folder must be EMPTY!

Go to the location of your file. The location where you downloaded the zipped folder for libgdx.

Navigate into the "extensions" folder and you should see these folders:

If you don't see them, then you dun goofed.

Here comes the trickiest part. Hold on to your seat.

Open up Notepad and using the folder locations, fill this code in (BE SURE TO USE FULL FILE PATHS!!! FROM THE CODE BELOW, YOU SHOULD BE ABLE TO FIGURE OUT WHICH FOLDERS THEY'RE REFERRING TO!!!):

java -classpath "***LOCATION_TO_LIBGDX_FOLDER***\libgdx-0.9.8\gdx.jar";"***LOCATION_TO_LIBGDX_FOLDER***\libgdx-0.9.8\extensions\gdx-tools\gdx-tools.jar";"***LOCATION_TO_LIBGDX_FOLDER***\libgdx-0.9.8\extensions\gdx-tiled-preprocessor\gdx-tiled-preprocessor.jar" com.badlogic.gdx.tiledmappacker.TiledMapPacker "***LOCATION_TO_SAVE_LOCATION_OF_ORIGINAL_MAP_AND_TILESETS***\resources\images" "***LOCATION_TO_WORKSPACE_GAME_FOLDER***\Game-android\assets\maps"

Simplified version without all the CAPS:
java -classpath "libgdx-0.9.8\gdx.jar";"libgdx-0.9.8\extensions\gdx-tools\gdx-tools.jar";"libgdx-0.9.8\extensions\gdx-tiled-preprocessor\gdx-tiled-preprocessor.jar" com.badlogic.gdx.tiledmappacker.TiledMapPacker "resources\images" "Game-android\assets\maps"

Now, save it as a .bat (This is what that "map_command.bat" was in one of the pictures above).

Run it!

In your game's workspace folder, the "assets\maps" folder should look something like this now:

Now you are ready to go to and continue following the wiki on how to use tile maps in your code.

Each time you create a new map or modify an existing one, you MUST clear out the "assets\maps" folder before running the .bat file.

Hopefully this tutorial helped you!
Online ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #1 - Posted 2013-02-15 04:50:26 »

Something that's irking me a bit: please show the file extensions. I don't know why everyone doesn't do that.

Otherwise, thanks for the tutorials!

Pages: [1]
  ignore  |  Print  

EgonOlsen (59 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (240 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!