Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flame_tiled - add centered anchor point for tile rotation #1570

Merged
merged 8 commits into from
Apr 28, 2022
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>