From f38e2506763204bf885729dc616baedefc7d6134 Mon Sep 17 00:00:00 2001 From: nathanaelneveux Date: Sat, 23 Apr 2022 23:12:06 -0400 Subject: [PATCH 1/5] Update renderable_tile_map.dart add centered anchor for rotations --- packages/flame_tiled/lib/src/renderable_tile_map.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/flame_tiled/lib/src/renderable_tile_map.dart b/packages/flame_tiled/lib/src/renderable_tile_map.dart index 15855a738d0..6d99331cf28 100644 --- a/packages/flame_tiled/lib/src/renderable_tile_map.dart +++ b/packages/flame_tiled/lib/src/renderable_tile_map.dart @@ -184,6 +184,7 @@ class RenderableTiledMap { offset: Vector2(tx * size.x, ty * size.y) ..add(layerOffset * size.x / src.width), rotation: flips.angle * math.pi / 2, + anchor: Vector2.all(0.5), scale: size.x / src.width, ); } From ae216477e1441c92c8f6cd90d1c5a9b8f7ccff47 Mon Sep 17 00:00:00 2001 From: nathanaelneveux Date: Sun, 24 Apr 2022 15:20:04 -0400 Subject: [PATCH 2/5] use non-normalized centered anchor point --- packages/flame_tiled/lib/src/renderable_tile_map.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flame_tiled/lib/src/renderable_tile_map.dart b/packages/flame_tiled/lib/src/renderable_tile_map.dart index 6d99331cf28..637c842bfc0 100644 --- a/packages/flame_tiled/lib/src/renderable_tile_map.dart +++ b/packages/flame_tiled/lib/src/renderable_tile_map.dart @@ -184,7 +184,7 @@ class RenderableTiledMap { offset: Vector2(tx * size.x, ty * size.y) ..add(layerOffset * size.x / src.width), rotation: flips.angle * math.pi / 2, - anchor: Vector2.all(0.5), + anchor: Vector2(size.x / 2, size.y / 2), scale: size.x / src.width, ); } From 51465df1a3f4f91da65926c943ba19828f335ecb Mon Sep 17 00:00:00 2001 From: nathanaelneveux Date: Sun, 24 Apr 2022 15:26:32 -0400 Subject: [PATCH 3/5] use src size --- packages/flame_tiled/lib/src/renderable_tile_map.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flame_tiled/lib/src/renderable_tile_map.dart b/packages/flame_tiled/lib/src/renderable_tile_map.dart index 637c842bfc0..23bb01abefc 100644 --- a/packages/flame_tiled/lib/src/renderable_tile_map.dart +++ b/packages/flame_tiled/lib/src/renderable_tile_map.dart @@ -184,7 +184,7 @@ class RenderableTiledMap { offset: Vector2(tx * size.x, ty * size.y) ..add(layerOffset * size.x / src.width), rotation: flips.angle * math.pi / 2, - anchor: Vector2(size.x / 2, size.y / 2), + anchor: Vector2(src.width / 2, src.height / 2), scale: size.x / src.width, ); } From f0a15ab31a34783deace94d121a855b4944c6c9c Mon Sep 17 00:00:00 2001 From: nathanaelneveux Date: Mon, 25 Apr 2022 22:15:40 -0400 Subject: [PATCH 4/5] compensate for anchor position offset in canvas offset --- packages/flame_tiled/lib/src/renderable_tile_map.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flame_tiled/lib/src/renderable_tile_map.dart b/packages/flame_tiled/lib/src/renderable_tile_map.dart index 23bb01abefc..007ecf8b499 100644 --- a/packages/flame_tiled/lib/src/renderable_tile_map.dart +++ b/packages/flame_tiled/lib/src/renderable_tile_map.dart @@ -181,7 +181,7 @@ 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), From 503b0dcd06f79010a47b0e40a92d203492ce10e9 Mon Sep 17 00:00:00 2001 From: nathanaelneveux Date: Tue, 26 Apr 2022 20:10:56 -0400 Subject: [PATCH 5/5] updated test file with rotated tile --- packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx b/packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx index b541386d163..1c1d732b71b 100644 --- a/packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx +++ b/packages/flame_tiled/test/assets/2_tiles-green_on_red.tmx @@ -1,6 +1,7 @@ - + + @@ -13,7 +14,7 @@ - eJxjZIAAAAAQAAI= + eJxjZGBYwAAEAAMwAKI=