Skip to content

Commit

Permalink
fix(flame_tiled): Add centered anchor point for tile rotation (#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelneveux committed Apr 28, 2022
1 parent c0e3257 commit f64d526
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/flame_tiled/lib/src/renderable_tile_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ class RenderableTiledMap {
if (batch != null) {
batch.add(
source: src,
offset: Vector2(tx * size.x, ty * size.y)
offset: Vector2((tx + .5) * size.x, (ty + .5) * size.y)
..add(layerOffset * size.x / src.width),
rotation: flips.angle * math.pi / 2,
anchor: Vector2(src.width / 2, src.height / 2),
scale: size.x / src.width,
);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="2" height="1" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
<map version="1.8" tiledversion="1.8.4" orientation="orthogonal" renderorder="right-down" width="2" height="1" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
<tileset firstgid="1" name="green_tile" tilewidth="16" tileheight="16" tilecount="1" columns="1">
<transformations hflip="1" vflip="1" rotate="1" preferuntransformed="0"/>
<image source="green_sprite.png" width="16" height="16"/>
</tileset>
<tileset firstgid="2" name="red_tile-base" tilewidth="16" tileheight="16" tilecount="1" columns="1">
Expand All @@ -13,7 +14,7 @@
</layer>
<layer id="1" name="green_tile-top" width="2" height="1">
<data encoding="base64" compression="zlib">
eJxjZIAAAAAQAAI=
eJxjZGBYwAAEAAMwAKI=
</data>
</layer>
</map>

0 comments on commit f64d526

Please sign in to comment.