Skip to content
New issue

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

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

Already on GitHub? # to your account

FollowCamera Scaling #697

Merged
merged 5 commits into from
Oct 26, 2021
Merged

FollowCamera Scaling #697

merged 5 commits into from
Oct 26, 2021

Conversation

Tobi-Mob
Copy link
Contributor

Short summary:
FollowCamera

  • Calculate Deadzone from Center instead of TopLeft of camera Bound.
  • Allow to provide Deadzone scale in % of ScreenSpace instead of pixels.
  • Allow Deadzone to scale with Zoom-Level.

Why?

  • The configured Deadzone moved to different positions in the world if the camera was zoomed.
  • FollowCamera.Follow(...) and SetCenteredDeadzone did not position the deadzone in the center of the screen, if a camera zoom is used.
  • I want my Deadzone to scale with the camera zoom.

So?
I modified the FollowCamera to fit my Zooming-Needs and maybe this is a good general addition.

Whats new?
The Deadzone can now be set in FixedPixel or in ScaledCameraBounds.

1)FixedSize:
Is almost like the old behavior, but the Deadzone now stays at the same place on the screen, even when zooming.
(instead of flying over the screen)

Fixed.mp4

2)ScaledCameraBounds:
Deadzone size is defined in % of CameraBounds. For Example SetCenteredDeadzoneInScreenspace(0.5f, 0.5f) will let the Deadzone always fill the inner 50% of the screen, regardless of Camera Zoom.

Scaled.mp4

What changed for developers when they ... ?

  • Call FollowCamera.Follow(...): Works as before, but now also positions the Deadzone in the Screen-Center if zoomed.
  • Call FollowCamera.SetCenteredDeadzone: (same as above)
  • Set Deadzone directly: Breaking Change the origin of the Deadzone is now in the Center of the camera instead of top-left. So a new Rectangle(-5, -5, 10 10) is now positioned in the center of the screen instead of top-left of the screen

* Calculate Deadzone from Center instead of TopLeft of camera Bound
* Allow to provide Deadzone scale in % of ScreenSpace instead of pixels
* Allow Deadzone to scale with Zoom-Level
@Tobi-Mob
Copy link
Contributor Author

I am open to any suggestions (I am not happy with my naming here, but had no better ideas).
If this is not a good addition to the framework, feel free to close this request.

@prime31 prime31 merged commit fb93e93 into prime31:master Oct 26, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants