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: Reset _completeCompleter in ticker #2636

Merged
merged 5 commits into from
Aug 7, 2023
Merged

Conversation

adil192
Copy link
Contributor

@adil192 adil192 commented Aug 2, 2023

Description

I was running this code:

void attack() async {
  print('Attack started');
  current = PlayerState.attack;

  final attackTicker = animationTicker!;
  await attackTicker.completed;
  print('Attack ticker completed');

  attackTicker.reset();
  current = PlayerState.idle;
}

and attackTicker.completed would get stuck as permanently completed after the first completion.

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

The closest issue I can find is #2584 which uses the ticker.onComplete function and ran into a problem because of creating a new ticker. This PR concerns the ticker.completed future.

@adil192 adil192 changed the title fix: reset _completeCompleter in ticker fix: Reset _completeCompleter in ticker Aug 2, 2023
@adil192 adil192 marked this pull request as ready for review August 2, 2023 03:15
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.

Thanks for your contribution, only an import fix needed and then it is ready for merge!

packages/flame/lib/src/sprite_animation_ticker.dart Outdated Show resolved Hide resolved
@spydon
Copy link
Member

spydon commented Aug 7, 2023

Ah, and this test also fails:

  ● SpriteAnimationWidget onComplete callback is called when the animation is finished packages/flame/test/widgets/sprite_animation_widget_test.dart:123:5

@spydon spydon enabled auto-merge (squash) August 7, 2023 17:05
@spydon spydon merged commit a35d3a1 into flame-engine:main Aug 7, 2023
6 checks passed
@adil192 adil192 deleted the patch-1 branch August 7, 2023 17:22
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.

2 participants