-
-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for Tiled 1.9.0 class property, #1182
- Loading branch information
Showing
4 changed files
with
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ import javax.xml.stream.events.StartElement | |
* @author Almas Baimagambetov ([email protected]) | ||
*/ | ||
|
||
private const val TILED_VERSION_LATEST = "1.4.2" | ||
private const val TILED_VERSION_LATEST = "1.9.0" | ||
|
||
class TMXLevelLoader | ||
@JvmOverloads constructor( | ||
|
@@ -133,6 +133,7 @@ class TMXLevelLoader | |
data.run { | ||
put("name", tiledObject.name) | ||
put("type", tiledObject.type) | ||
put("class", tiledObject.type) | ||
put("width", tiledObject.width) | ||
put("height", tiledObject.height) | ||
put("rotation", tiledObject.rotation) | ||
|
@@ -407,13 +408,19 @@ class TMXLevelLoader | |
private fun parseObject(layer: Layer, obj: TiledObject, start: StartElement) { | ||
obj.name = start.getString("name") | ||
obj.type = start.getString("type") | ||
obj.typeClass = start.getString("class") | ||
obj.id = start.getInt("id") | ||
obj.x = start.getInt("x") | ||
obj.y = start.getInt("y") | ||
obj.rotation = start.getFloat("rotation") | ||
obj.width = start.getInt("width") | ||
obj.height = start.getInt("height") | ||
|
||
// re-map semantics for 1.9+ | ||
if (obj.typeClass.isNotEmpty() && obj.type.isEmpty()) { | ||
obj.type = obj.typeClass | ||
} | ||
|
||
// gid is stored as UInt, so parsing as int gives incorrect representation | ||
val gidUInt = start.getUInt("gid") | ||
|
||
|
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
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
36 changes: 36 additions & 0 deletions
36
fxgl-entity/src/test/resources/com/almasb/fxgl/entity/level/tiled/sewers_v1_9_0.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,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="24" tileheight="24" infinite="0" nextlayerid="5" nextobjectid="7"> | ||
<tileset firstgid="1" name="sewer_tileset" tilewidth="24" tileheight="24" tilecount="72" columns="8"> | ||
<image source="sewer_tileset.png" trans="ff00ff" width="192" height="217"/> | ||
</tileset> | ||
<layer id="1" name="Bottom" width="64" height="64"> | ||
<data encoding="base64" compression="zlib"> | ||
eJztmN1qwkAQRpfeabWgFaHqja1af97D93+kjpiBZdikmwTd7Ho+OFCMRc+E4Vszdc59CN8VE2HqvfYjbCq25rp/LfSetvjfw372f3SN/Vz84/13wlnYV9z+PmTuvxDehGWEf4n3fySMhfce/jrDtujMU/rPhLnw2cNfZxjit+Gazlz36pLA39LFX2focwy8ZgnNPDf/k7vfuz60ue9D679UDMX/S1gJ6xf13wb+b8j+tnf69r/uf5cdTuHv905M//vzKWH//d6J6X9/PiXsf13v1fXfbT7Xaj4l7H+bLrbdHtrx3PY/xa7ijz/++fhrp1me3XGp/LXTmroxNY/2t8+0Svn9F+tvn2mVcv6N9bfPtOrOv6X667l37prPvyX61z3TevYZN5V/DuCPP/74448//vjjjz/++OOPP/74448//vjjjz8hhBBCCCGEkNfLHzZhCrU= | ||
</data> | ||
</layer> | ||
<layer id="2" name="Top" width="64" height="64" opacity="0.49"> | ||
<data encoding="base64" compression="zlib"> | ||
eJzt1zEOwjAQRFEXhCrJVVKEQIHouP+Z2CK+AhPJ70lfbsfltnYtz/SAMP8f22j/36r97FEd2Tl/96re1fd8P9k57VZN1T28I2WulmpNDwEAAAjpd2FvtPuw34U99yEAAAAAAAAAAAAACT+/lQOV | ||
</data> | ||
</layer> | ||
<objectgroup id="3" name="Collidables"> | ||
<object id="1" name="name1" class="type1" x="96" y="0" width="72" height="336"> | ||
<properties> | ||
<property name="collidable" type="bool" value="true"/> | ||
<property name="someColor" type="color" value="#ff55ff00"/> | ||
<property name="someInt" type="int" value="33"/> | ||
<property name="someString" value="Text Here"/> | ||
</properties> | ||
</object> | ||
<object id="2" name="name2" class="type2" x="504" y="0" width="360" height="168" rotation="31"/> | ||
<object id="4" name="polygon_name" class="no_type" x="696" y="504"> | ||
<polygon points="0,0 120,-72 192,48 24,48"/> | ||
</object> | ||
<object id="6" name="polyline_name" class="no_type" x="936" y="432"> | ||
<polyline points="0,0 96,0 96,-96 192,-96 192,96 24,96"/> | ||
</object> | ||
</objectgroup> | ||
<objectgroup id="4" name="Group2"> | ||
<object id="3" name="no name" x="240" y="504" width="120" height="120"/> | ||
</objectgroup> | ||
</map> |