Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
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 4775 times)
0 Members and 1 Guest are viewing this topic.
Offline vbrain
« Posted 2013-02-14 05: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 libgdx.zip 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!!!):

1  
2  
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"
pause


Simplified version without all the CAPS:
1  
2  
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"
pause


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 http://code.google.com/p/libgdx/wiki/GraphicsTileMaps 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!
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #1 - Posted 2013-02-15 05: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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (50 views)
2014-04-15 18:08:23

BurntPizza (46 views)
2014-04-15 03:46:01

UprightPath (62 views)
2014-04-14 17:39:50

UprightPath (44 views)
2014-04-14 17:35:47

Porlus (61 views)
2014-04-14 15:48:38

tom_mai78101 (84 views)
2014-04-10 04:04:31

BurntPizza (142 views)
2014-04-08 23:06:04

tom_mai78101 (242 views)
2014-04-05 13:34:39

trollwarrior1 (201 views)
2014-04-04 12:06:45

CJLetsGame (208 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!