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: Auto-resize SpriteComponent on sprite change #2430

Merged
merged 7 commits into from
Mar 26, 2023

Conversation

ufrshubham
Copy link
Member

@ufrshubham ufrshubham commented Mar 25, 2023

Description

This PR adds an autoResize parameter to SpriteComponent using which users will be able to control if the component should auto-resize on sprite change to match the sprite's srcSize. Some important design decisions about autoResize:

  • It is mutually exclusive with size while construction: This means, if size is non-null while construction of SpriteComponent, autoResize cannot be true. This allows use-cases where one might want to render a sprite at a different size than its original size. If an user is setting the size explicitly, we can leave it up to them to handle resizing in such cases.

  • It is optional: If an user does not set this parameter while construction, it will be auto-populated depending upon if a size is provided or not.

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 #2419

@ufrshubham ufrshubham requested a review from spydon March 25, 2023 07:09
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.

Lgtm, just some small nits :)

packages/flame/lib/src/components/sprite_component.dart Outdated Show resolved Hide resolved
packages/flame/lib/src/components/sprite_component.dart Outdated Show resolved Hide resolved
Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@erickzanardo erickzanardo left a comment

Choose a reason for hiding this comment

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

Awesome idea! Addded a couple of comments before approving

@spydon spydon merged commit 158460d into main Mar 26, 2023
@spydon spydon deleted the devkage/sprite-component-auto-resize branch March 26, 2023 18:14
spydon pushed a commit that referenced this pull request Apr 1, 2023
…ationGroupComponent` (#2453)

This PR extends autoResize to SpriteAnimationComponent and SpriteAnimationGroupComponent similar to what was done in #2430 and #2442.

Additionally, this PR also adds playing property to SpriteAnimationGroupComponent. If it is desired to make this appear as a separate entry in the changlog, I can move this change to a separate PR as it is completely unrelated to the auto-resize changes.
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.

SpriteComponent doesn't auto-resize
4 participants