flixel icon indicating copy to clipboard operation
flixel copied to clipboard

FlxTween.cancelChain() doesn't function correctly if tween has completed

Open MondayHopscotch opened this issue 2 years ago • 1 comments

  • Haxe version: 4.2.4
  • Flixel version: 5.2.2
  • OpenFL version: 9.2.1
  • Lime version: 7.9.0
  • Affected targets: All

Code snippet reproducing the issue: https://github.com/MondayHopscotch/TweenTest)https://github.com/MondayHopscotch/TweenTest


Reproduction steps:

  1. Create a tween with chained tweens (Tween.then(Tween))
  2. Save initial tween as variable (ex: var mainTween:FlxTween)
  3. After parent tween has completed, attempt to call mainTween.cancelChain()

Observed behavior: Tween chain continues despite .cancelChain() being called on parent tween.

Expected behavior: All tweens chained under parent tween are canceled.

In the case of my example project, expected behavior is that the square sprite stops tweening halfway through turning blue.

Extra Context: https://discord.com/channels/162395145352904705/165234904815239168/1069465074219098122

This line is the culprit with how the current default manager operates: https://github.com/HaxeFlixel/flixel/commit/b2436a63ccdb24f431088f06e5c4b06420126dde

MondayHopscotch avatar May 10 '23 18:05 MondayHopscotch

This is a tough one. Ideally we should delay the destruction of chained tweens until the chain in complete but, truthfully, I don't know if there's a simple solution. commenting out _nextTweenInChain = null; works but that can cause memory leaks. tween chaining is kind of complicated, since you can chain multiple tweens to a single tween but also chain tweens to chained tweens.

I'll need to think about this for a bit

Geokureli avatar May 15 '23 16:05 Geokureli