forked from libgdx/libgdx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Parsing imagelayer inside a group tag in TMX file (libgdx#7135)
* added failed test for parsing imagelayer inside a group tag. * fixed the test for parsing imagelayer inside a group tag. * removed unused group tags from `test.tmx` * after `./gradlew spotlessApply` * updated TiledMapGroupLayerWithImagelayerTest * Rename .tsx.tsx. to .tsx --------- Co-authored-by: SimonIT <[email protected]>
- Loading branch information
Showing
13 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...tests-android/assets/data/maps/tiled-groups-imagelayer/Lonesome_Forest_Summer_Tileset.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<tileset version="1.10" tiledversion="1.10.1" name="Lonesome_Forest_Summer_Tileset.tsx" tilewidth="32" tileheight="32" tilecount="1" columns="1"> | ||
<image source="tileset/badlogicsmall.jpg" width="32" height="32"/> | ||
<wangsets> | ||
<wangset name="Unnamed Set" type="mixed" tile="-1"> | ||
<wangcolor name="" color="#ff0000" tile="-1" probability="1"/> | ||
<wangcolor name="" color="#00ff00" tile="-1" probability="1"/> | ||
<wangtile tileid="0" wangid="1,1,1,1,1,1,1,1"/> | ||
</wangset> | ||
</wangsets> | ||
</tileset> |
63 changes: 63 additions & 0 deletions
63
tests/gdx-tests-android/assets/data/maps/tiled-groups-imagelayer/test.tmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="32" tileheight="32" infinite="0" nextlayerid="22" nextobjectid="1"> | ||
<tileset firstgid="1" source="Lonesome_Forest_Summer_Tileset.tsx"/> | ||
<layer id="1" name="Tile Layer 1" width="10" height="10"> | ||
<data encoding="csv"> | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
0,0,0,0,0,0,0,0,0,0, | ||
1,0,0,0,0,0,0,0,0,1, | ||
0,0,0,0,0,0,0,0,0,0, | ||
1,0,0,0,0,0,0,0,0,1 | ||
</data> | ||
</layer> | ||
<group id="4" name="Group 2"> | ||
<imagelayer id="5" name="Image Layer 2" offsetx="111.654" offsety="-0.8052"> | ||
<image source="tileset/test_image2.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
<group id="7" name="Group 4"> | ||
<group id="8" name="Group 5"> | ||
<group id="9" name="Group 6"> | ||
<group id="6" name="Group 3"/> | ||
<group id="11" name="Group 7"> | ||
<group id="17" name="Group 10"> | ||
<group id="19" name="Group 12"> | ||
<group id="18" name="Group 11"> | ||
<group id="14" name="Group 9"> | ||
<imagelayer id="16" name="Image Layer 6" offsetx="230.019" offsety="117.559"> | ||
<image source="tileset/test_image6.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
</group> | ||
</group> | ||
<group id="20" name="Group 13"/> | ||
<imagelayer id="21" name="Image Layer 7" offsetx="103.871" offsety="230.556"> | ||
<image source="tileset/test_image7.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
<group id="13" name="Group 8"> | ||
<imagelayer id="15" name="Image Layer 5" offsetx="114.607" offsety="118.633"> | ||
<image source="tileset/test_image5.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
</group> | ||
<imagelayer id="12" name="Image Layer 4" offsetx="0" offsety="118.096"> | ||
<image source="tileset/test_image4.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
<imagelayer id="10" name="Image Layer 3" offsetx="223.846" offsety="-0.5368"> | ||
<image source="tileset/test_image3.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
</group> | ||
<group id="2" name="Group 1"> | ||
<imagelayer id="3" name="Image Layer 1"> | ||
<image source="tileset/test_image.png" width="112" height="112"/> | ||
</imagelayer> | ||
</group> | ||
</map> |
Binary file added
BIN
+1.75 KB
...ests-android/assets/data/maps/tiled-groups-imagelayer/tileset/badlogicsmall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.29 KB
...x-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.49 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.51 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.41 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.39 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.61 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.39 KB
...-tests-android/assets/data/maps/tiled-groups-imagelayer/tileset/test_image7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions
87
tests/gdx-tests/src/com/badlogic/gdx/tests/TiledMapGroupLayerWithImagelayerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
package com.badlogic.gdx.tests; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.assets.AssetDescriptor; | ||
import com.badlogic.gdx.assets.AssetErrorListener; | ||
import com.badlogic.gdx.assets.AssetManager; | ||
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver; | ||
import com.badlogic.gdx.graphics.OrthographicCamera; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader; | ||
import com.badlogic.gdx.maps.tiled.TiledMap; | ||
import com.badlogic.gdx.maps.tiled.TiledMapRenderer; | ||
import com.badlogic.gdx.maps.tiled.TmxMapLoader; | ||
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | ||
import com.badlogic.gdx.tests.utils.GdxTest; | ||
import com.badlogic.gdx.tests.utils.OrthoCamController; | ||
import com.badlogic.gdx.utils.ScreenUtils; | ||
|
||
public class TiledMapGroupLayerWithImagelayerTest extends GdxTest { | ||
|
||
private TiledMap map; | ||
private TiledMapRenderer renderer; | ||
private OrthographicCamera camera; | ||
private OrthoCamController cameraController; | ||
private AssetManager assetManager; | ||
private BitmapFont font; | ||
private SpriteBatch batch; | ||
String errorMessage; | ||
private String fileName = "data/maps/tiled-groups-imagelayer/test.tmx"; | ||
|
||
@Override | ||
public void create () { | ||
float w = Gdx.graphics.getWidth(); | ||
float h = Gdx.graphics.getHeight(); | ||
|
||
camera = new OrthographicCamera(); | ||
camera.setToOrtho(false, (w / h) * 10, 10); | ||
camera.zoom = 2; | ||
camera.update(); | ||
|
||
cameraController = new OrthoCamController(camera); | ||
Gdx.input.setInputProcessor(cameraController); | ||
|
||
font = new BitmapFont(); | ||
batch = new SpriteBatch(); | ||
|
||
AtlasTmxMapLoader.AtlasTiledMapLoaderParameters params = new AtlasTmxMapLoader.AtlasTiledMapLoaderParameters(); | ||
params.forceTextureFilters = true; | ||
params.textureMinFilter = Texture.TextureFilter.Linear; | ||
params.textureMagFilter = Texture.TextureFilter.Linear; | ||
|
||
assetManager = new AssetManager(); | ||
assetManager.setErrorListener(new AssetErrorListener() { | ||
@Override | ||
public void error (AssetDescriptor asset, Throwable throwable) { | ||
errorMessage = throwable.getMessage(); | ||
} | ||
}); | ||
|
||
assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); | ||
assetManager.load(fileName, TiledMap.class); | ||
} | ||
|
||
@Override | ||
public void render () { | ||
ScreenUtils.clear(100f / 255f, 100f / 255f, 250f / 255f, 1f); | ||
camera.update(); | ||
assetManager.update(16); | ||
if (renderer == null && assetManager.isLoaded(fileName)) { | ||
map = assetManager.get(fileName); | ||
renderer = new OrthogonalTiledMapRenderer(map, 1f / 32f); | ||
} else if (renderer != null) { | ||
renderer.setView(camera); | ||
renderer.render(); | ||
} | ||
batch.begin(); | ||
if (errorMessage != null) { | ||
font.draw(batch, "ERROR (OK if running in GWT): " + errorMessage, 10, 50); | ||
System.out.println(errorMessage); | ||
} | ||
font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 10, 20); | ||
batch.end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters