Skip to content

Commit

Permalink
fix: [#449] Respect inserted tile size (#450)
Browse files Browse the repository at this point in the history
Closes: #449 

Allows custom sizing of inserted tiles 

<img width="191" alt="image" src="https://github.com/excaliburjs/excalibur-tiled/assets/612071/7b4bae96-408c-47dc-80ee-072a787e3015">
  • Loading branch information
eonarheim authored Aug 3, 2023
1 parent 32bed99 commit 1e77eef
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/example-city-base64.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
</object>
<object id="4" gid="1073741992" x="640" y="176" width="16" height="16"/>
<object id="5" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
1 change: 1 addition & 0 deletions example/example-city-external-tsx.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,6 @@
</object>
<object id="4" gid="1073741992" x="640" y="176" width="16" height="16"/>
<object id="5" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
1 change: 1 addition & 0 deletions example/example-city-gzip.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
</object>
<object id="4" gid="1073741992" x="640" y="176" width="16" height="16"/>
<object id="5" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
1 change: 1 addition & 0 deletions example/example-city-zlib.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
</object>
<object id="4" gid="1073741992" x="640" y="176" width="16" height="16"/>
<object id="5" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
1 change: 1 addition & 0 deletions example/example-city-zstd.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
</object>
<object id="4" gid="1073741992" x="640" y="176" width="16" height="16"/>
<object id="5" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
15 changes: 14 additions & 1 deletion example/example-city.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,20 @@
"width":16,
"x":592,
"y":176
}],
},
{
"gid": 252,
"height": 32,
"width": 32,
"id": 9,
"name": "",
"rotation": 0,
"type": "",
"visible": true,
"x": 383.636,
"y": 128.182
}
],
"opacity":1,
"properties":[
{
Expand Down
7 changes: 4 additions & 3 deletions example/example-city.tmx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.9" tiledversion="1.9.0" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="16" tileheight="16" infinite="0" nextlayerid="13" nextobjectid="9">
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="16" tileheight="16" infinite="0" nextlayerid="13" nextobjectid="10">
<tileset firstgid="1" name="Kenny RPG Urban Pack" tilewidth="16" tileheight="16" tilecount="486" columns="27">
<image source="assets/kenny-rpg-urban-pack/tilemap_packed.png" width="432" height="288"/>
<tile id="190">
Expand Down Expand Up @@ -1120,10 +1120,10 @@
<properties>
<property name="excalibur" type="bool" value="true"/>
</properties>
<object id="6" name="player-start" class="player-start" x="375" y="104">
<object id="6" name="player-start" type="player-start" x="375" y="104">
<point/>
</object>
<object id="7" name="Camera" class="Camera" x="444.5" y="404.5">
<object id="7" name="Camera" type="Camera" x="444.5" y="404.5">
<properties>
<property name="Zoom" type="float" value="4"/>
</properties>
Expand All @@ -1137,5 +1137,6 @@
<object id="1" name="StopLight" gid="409" x="304" y="112" width="16" height="16"/>
<object id="4" name="SignPost" gid="168" x="640" y="176" width="16" height="16"/>
<object id="5" name="StopLight" gid="2147484058" x="592" y="176" width="16" height="16"/>
<object id="9" gid="252" x="383.636" y="128.182" width="32" height="32"/>
</objectgroup>
</map>
3 changes: 3 additions & 0 deletions src/tiled-map-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ export class TiledMapResource implements Loadable<TiledMap> {
}
actor.addComponent(new TiledObjectComponent(tile));
actor.graphics.anchor = vec(0, 1);
// respect tile size on sprite
sprite.destSize.width = tile.width ?? sprite.destSize.width;
sprite.destSize.height = tile.height ?? sprite.destSize.height;
actor.graphics.use(sprite);
scene.add(actor);
actor.z = this._calculateZIndex(tile, objectLayer);
Expand Down
Binary file modified test/integration/images/expected-play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1e77eef

Please sign in to comment.