I learned (12)-I encountered a bunch of problems when using the tiledmap. I was so sad for several days.
1. Process tmx files
The document says: Use the tile map editor tool to create a tmx file and then use GDX-tiled-Preprocessor to process it. After processing is completed, three more files will be added to overwrite the original file with the same name.
In the end, I encountered a problem. I did not reply to the author on Weibo. I went on to find a solution and finally met a netizen. Here are some solutions:
1) After the tmx file is created, check the image path used. It cannot be an absolute path: (I changed it to a relative path)
Open the tmx file in text format and find the source = "screenshot-isometric.png". If it is an absolute path, copy the image and change it to a relative path.
2) use GDX-tiled-Preprocessor to process tmx files
The libgdx I'm using is the latest 0.9.8, where there is a gdx-tiled-preprocessor.jar file, as described online,
Create a folder (any name of tiledmap can be used), store the JAR file, create two subfolders: In and out, and put the tmx file and the image file used into the in
Run the Java-jar gdx-tiled-preprocessor.jar in out command in the tiledmap file.
Finally, my solution is to put GDX. Jar under the tiledmap file (which is easy to find), gdx-tools.jar (under the extensions/GDX-tools directory) and gdx-tiled-preprocessor.jar Three jar
Run the java-classpath gdx. jar; gdx-tools.jar; gdx-tiled-preprocessor.jar com. badlogic. gdx. tiledmappacker. TiledMapPacker in out
Done.
************ ******************
2. Error: com. badlogic. gdx. utils. GdxRuntimeException: Error reading file: map/tmw-desert-spacing packfile (Absolute)
Solution:
Atlas = new TileAtlas (map, new FileHandle ("data/map /");
Atlas = new TileAtlas (map, Gdx. files. internal ("data/map/"); OK
3. Error: java. lang. IllegalArgumentException: Bad position (limit 0): 8
Error reported by code tileMapRenderer. render (c); (c is the camera variable obtained from the stage)
This problem has plagued me for a few nights and I have not found any answers on the Internet ............
Finally, I accidentally discovered that there was a problem with image creation. I couldn't open the tmx file when I opened it with Tiled Map Editor... A few days ago ...... depressing