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

feat: Added AnchorToEffect and AnchorByEffect #1556

Merged
merged 13 commits into from
Apr 21, 2022

Conversation

st-pasha
Copy link
Contributor

@st-pasha st-pasha commented Apr 19, 2022

Description

  • Added AnchorProvider interface, currently implemented by PositionComponent and Viewfinder.
  • Added AnchorToEffect and AnchorByEffect that can be applied to a target which is an AnchorProvider.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • 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.

Breaking Change

  • [-] Yes, this is a breaking change.
  • No, this is not a breaking change.

Copy link
Contributor

@wolfenrain wolfenrain left a comment

Choose a reason for hiding this comment

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

LGTM

@st-pasha st-pasha marked this pull request as draft April 20, 2022 17:09
@st-pasha
Copy link
Contributor Author

It just occurred to me that AnchorByEffect will also be useful to have.

@erickzanardo
Copy link
Member

Can you share a use case for this? Just really curious, never thought myself on animating a component anchor

@st-pasha
Copy link
Contributor Author

We already have Anchor effects in the current camera, only it's called relativeOffset there, and when you call setRelativeOffset(Anchor newRelativeOffset), it applies a smooth transition of the anchor. So, AnchorToEffect() is an equivalent mechanism for the new camera, but allows a finer control over the timing of the transition.

Then, there is camera shake. It can also be done via an effect -- either affecting the camera's position, or the camera's anchor. It occurs to me that doing the shake via an anchor effect would be more reliable, since the camera's position is already affected by various behaviors such as follow-component of world-boundary. So, this is where AnchorEffect.by would come in: add a tiny amount of random offset to the camera's anchor, and it shakes nicely without any interference from the position behaviors.

@st-pasha st-pasha marked this pull request as ready for review April 21, 2022 07:08
@st-pasha st-pasha changed the title feat: Added AnchorToEffect feat: Added AnchorToEffect and AnchorByEffect Apr 21, 2022
@spydon spydon enabled auto-merge (squash) April 21, 2022 17:35
@spydon spydon merged commit eff7279 into flame-engine:main Apr 21, 2022
@st-pasha st-pasha deleted the ps/anchor-effect branch April 21, 2022 18:35
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.

4 participants