-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
(sorry im not getting the list to fill out, ill just fill in the issue as best as i can)
[OS]
Win10
[Phaser version]
3.60.0-beta.9
[Trivia]
calling killTweensOf(target) on a target on which tween has been recently created (set to paused:false [or default eg 'not set']) does not stop said tween and rather the 'tween runs anyways'.
[Code to repro]
go to labs example:
https://labs.phaser.io/edit.html?src=src/tweens/immediate%20stop%20a%20tween.js&v=3.55.2
Copy paste following code and replace create() function in labs example:
function create ()
{
var marker = this.add.image(100, 300, 'block').setAlpha(0.3);
var image = this.add.image(100, 300, 'block');
var tween = this.tweens.add({
targets: image,
x: 700,
delay: 1000,
duration: 6000,
ease: 'Power2'
});
// doesnt stop tween
this.tweens.killTweensOf(image);
this.input.on('pointerdown', ()=>{
// does stop tween
this.tweens.killTweensOf(image);
});
}
I can also confirm, that keeping an instance of created tween and calling myTween.stop()
does stop the tween properly, but in my use-case keeping an instance is not preferable.
[Suggestion]
Reading the docs, on the surface it seems the tween should be stopped (bug herein reported), but also flagged to be removed from TweenManager, but the removal happens 'start of next frame'. I wonder if this could interfere with trying to use the same tween in the same frame (possibly from elsewhere) right after the kill, or some other such edge cases (using the reference in the same frame for 'reasons' eg 'other code not knowing that the kill happened and the reference shouldnt be used until next frame' or other). I wonder, would having a 'removeImmediately' flag to remove the tween from TM instantly (synchronously) help to alleviate such edge cases (whilst incurring perf overhead-which might be preferable)? Just worrying a bit about delayed cleanup whils some code that executes in current frame might want to use/create new of same instance, which is not fully collected (maybe i'm overthinking it).
[Possibly related]
(1) Issue: #6169
(2) might also affect myScene.tweens.addCounter (UNTESTED) and should be solved-for there as well.