-
-
Notifications
You must be signed in to change notification settings - Fork 895
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: Tiled component orthogonal test #2549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! 💙
packages/flame_tiled/lib/src/renderable_layers/renderable_layer.dart
Outdated
Show resolved
Hide resolved
final anchor = camera.viewfinder.anchor; | ||
final cameraX = camera.viewfinder.position.x; | ||
final cameraY = camera.viewfinder.position.y; | ||
final viewportCenterX = camera.viewport.size.x * anchor.x; | ||
final viewportCenterY = camera.viewport.size.y * anchor.y; | ||
final viewportCenterX = camera.viewport.size.x / 2; | ||
final viewportCenterY = camera.viewport.size.y / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this in Flame and compare it to Tiled? I originally verified everything lined up by hand
|
||
// Need to initialize a game and call `onLoad` and `onGameResize` to | ||
// get the camera and canvas sizes all initialized | ||
final game = FlameGame(children: [world, cameraComponent]); | ||
await game.ready(); | ||
cameraComponent.viewfinder.anchor = Anchor.center; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, following up the logic that we need to apply the camera's anchor to the parallax, I thought that, hey, maybe the code previously was already correct, but with the previous camera, tiled was always considering a center camera, hence why it was doing a / 2
, which would make the generated snapshots be based on a Anchor.center
camera.
So for the test to pass, I just changed the camera's anchor on the test to center, to match the previous behaviour, which seems to make sense to me.
Let me know if this also make sense to you all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to make sense!
Description
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
Closes #2548