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: Tiled component orthogonal test #2549

Merged
merged 9 commits into from
Jun 6, 2023
Merged

Conversation

erickzanardo
Copy link
Member

@erickzanardo erickzanardo commented May 23, 2023

Description

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #2548

@erickzanardo erickzanardo requested review from spydon and a team May 23, 2023 12:02
@erickzanardo erickzanardo changed the title fix: tiled component orthogonal test fix: Tiled component orthogonal test May 23, 2023
Copy link
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! 💙

@spydon spydon enabled auto-merge (squash) June 5, 2023 12:10
@spydon spydon disabled auto-merge June 5, 2023 12:16
Comment on lines 109 to 112
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;
Copy link
Contributor

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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spydon @kurtome @ufrshubham

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to make sense!

@erickzanardo erickzanardo merged commit 34e5f0e into main Jun 6, 2023
6 checks passed
@erickzanardo erickzanardo deleted the erick.fix-flame-tiled-test branch June 6, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flame_tiled is failing the goldens in Flutter 3.10
4 participants