Description
Creating a tween with targets that include null, undefined, or
destroyed game objects will cause a runtime error in TweenBuilder.
This happens because the scale shortcut logic calls:
target.hasOwnProperty('scale')
without checking whether target is valid.
Reproduction
var sprite = this.add.sprite(400, 300, 'logo');
sprite.destroy();
this.tweens.add({
targets: [sprite, null, undefined],
x: 500,
duration: 1000
});
Error:
TypeError: Cannot read properties of null (reading 'hasOwnProperty')
Expected behavior
Invalid targets should be skipped instead of causing a crash.
Affected versions
Phaser 3.53.1 → 3.90.0
Related PR
Fix PR: #7211