FlxTween.cancelChain() doesn't function correctly if tween has completed
- 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:
- Create a tween with chained tweens (
Tween.then(Tween)) - Save initial tween as variable (ex:
var mainTween:FlxTween) - 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
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