+47
-2
lines changedFilter options
+47
-2
lines changed Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ import javax.xml.stream.events.StartElement
33
33
* @author Almas Baimagambetov (almaslvl@gmail.com)
34
34
*/
35
35
36
-
private const val TILED_VERSION_LATEST = "1.4.2"
36
+
private const val TILED_VERSION_LATEST = "1.9.0"
37
37
38
38
class TMXLevelLoader
39
39
@JvmOverloads constructor(
@@ -133,6 +133,7 @@ class TMXLevelLoader
133
133
data.run {
134
134
put("name", tiledObject.name)
135
135
put("type", tiledObject.type)
136
+
put("class", tiledObject.type)
136
137
put("width", tiledObject.width)
137
138
put("height", tiledObject.height)
138
139
put("rotation", tiledObject.rotation)
@@ -407,13 +408,19 @@ class TMXLevelLoader
407
408
private fun parseObject(layer: Layer, obj: TiledObject, start: StartElement) {
408
409
obj.name = start.getString("name")
409
410
obj.type = start.getString("type")
411
+
obj.typeClass = start.getString("class")
410
412
obj.id = start.getInt("id")
411
413
obj.x = start.getInt("x")
412
414
obj.y = start.getInt("y")
413
415
obj.rotation = start.getFloat("rotation")
414
416
obj.width = start.getInt("width")
415
417
obj.height = start.getInt("height")
416
418
419
+
// re-map semantics for 1.9+
420
+
if (obj.typeClass.isNotEmpty() && obj.type.isEmpty()) {
421
+
obj.type = obj.typeClass
422
+
}
423
+
417
424
// gid is stored as UInt, so parsing as int gives incorrect representation
418
425
val gidUInt = start.getUInt("gid")
419
426
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@ class TiledObject(var id: Int = 0,
18
18
var height: Int = 0,
19
19
var name: String = "",
20
20
var type: String = "",
21
+
// from 1.9
22
+
var typeClass: String = "",
21
23
var visible: Boolean = true,
22
24
var x: Int = 0,
23
25
var y: Int = 0,
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ class TMXLevelLoaderTest {
190
190
}
191
191
192
192
@ParameterizedTest
193
-
@CsvSource("sewers_v1_1_2.tmx", "sewers_v1_2_3.tmx")
193
+
@CsvSource("sewers_v1_1_2.tmx", "sewers_v1_2_3.tmx", "sewers_v1_9_0.tmx")
194
194
fun parse(mapName: String) {
195
195
val map = javaClass.getResourceAsStream(mapName).use {
196
196
TMXLevelLoader().parse(it)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
1
+
<?xml version="1.0" encoding="UTF-8"?>
2
+
<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">
3
+
<tileset firstgid="1" name="sewer_tileset" tilewidth="24" tileheight="24" tilecount="72" columns="8">
4
+
<image source="sewer_tileset.png" trans="ff00ff" width="192" height="217"/>
5
+
</tileset>
6
+
<layer id="1" name="Bottom" width="64" height="64">
7
+
<data encoding="base64" compression="zlib">
8
+
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=
9
+
</data>
10
+
</layer>
11
+
<layer id="2" name="Top" width="64" height="64" opacity="0.49">
12
+
<data encoding="base64" compression="zlib">
13
+
eJzt1zEOwjAQRFEXhCrJVVKEQIHouP+Z2CK+AhPJ70lfbsfltnYtz/SAMP8f22j/36r97FEd2Tl/96re1fd8P9k57VZN1T28I2WulmpNDwEAAAjpd2FvtPuw34U99yEAAAAAAAAAAAAACT+/lQOV
14
+
</data>
15
+
</layer>
16
+
<objectgroup id="3" name="Collidables">
17
+
<object id="1" name="name1" class="type1" x="96" y="0" width="72" height="336">
18
+
<properties>
19
+
<property name="collidable" type="bool" value="true"/>
20
+
<property name="someColor" type="color" value="#ff55ff00"/>
21
+
<property name="someInt" type="int" value="33"/>
22
+
<property name="someString" value="Text Here"/>
23
+
</properties>
24
+
</object>
25
+
<object id="2" name="name2" class="type2" x="504" y="0" width="360" height="168" rotation="31"/>
26
+
<object id="4" name="polygon_name" class="no_type" x="696" y="504">
27
+
<polygon points="0,0 120,-72 192,48 24,48"/>
28
+
</object>
29
+
<object id="6" name="polyline_name" class="no_type" x="936" y="432">
30
+
<polyline points="0,0 96,0 96,-96 192,-96 192,96 24,96"/>
31
+
</object>
32
+
</objectgroup>
33
+
<objectgroup id="4" name="Group2">
34
+
<object id="3" name="no name" x="240" y="504" width="120" height="120"/>
35
+
</objectgroup>
36
+
</map>
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4