You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you pass in an array as the targets property for a tween config, and then change that array, specifically if you insert elements into the array, the whole array doesn't tween and any elements outside of the original length of the array won't get tweened.
Example Test Code
export default class ArrayTweenIssue extends Phaser.Scene {
create() {
this.add.circle(0,0,100, 0xff0000);
this.add.rectangle(this.scale.width,0,100, 100, 0x00ff00);
this.add.ellipse(0,this.scale.height,100, 100, 0x00ff00);
this.add.star(this.scale.width,this.scale.height,5, 25, 100, 0x00ff00);
this.tweens.add({ targets: this.children.list, duration: 1000, props: { x: this.scale.width / 2, y: this.scale.height / 2 } });
// add another item afterwards
const t = this.add.text(this.scale.width / 2, this.scale.height / 2, 'Test Text', { align: 'center' }).setOrigin(0.5);
// move it so that it's within the original lists count
this.children.moveTo(t, 1);
}
}
In the example above, you would sort of expect the 4 shapes to tween towards the center, but the star doesn't. In Phaser 3.55.2, all of the shapes would still tween towards the center. If the text wasn't added at the center, it would get tweened towards the center (in both Phaser 3.55.2 and Phaser 3.86.0).
Additional Information
This use to work correctly in Phaser 3.55.2. This may be intended. My guess is that somewhere the length of the array is being stored so if the array length changes, the old array length is still used. However, it doesn't seem to affect if you remove an element from the array - such as destroying one of the gameobjects to cause this.children.list to be smaller than it originally was, I thought maybe would cause null reference errors but it doesn't.
The text was updated successfully, but these errors were encountered:
Version
Description
If you pass in an array as the
targets
property for a tween config, and then change that array, specifically if you insert elements into the array, the whole array doesn't tween and any elements outside of the original length of the array won't get tweened.Example Test Code
In the example above, you would sort of expect the 4 shapes to tween towards the center, but the star doesn't. In Phaser 3.55.2, all of the shapes would still tween towards the center. If the text wasn't added at the center, it would get tweened towards the center (in both Phaser 3.55.2 and Phaser 3.86.0).
Additional Information
This use to work correctly in Phaser 3.55.2. This may be intended. My guess is that somewhere the length of the array is being stored so if the array length changes, the old array length is still used. However, it doesn't seem to affect if you remove an element from the array - such as destroying one of the gameobjects to cause
this.children.list
to be smaller than it originally was, I thought maybe would cause null reference errors but it doesn't.The text was updated successfully, but these errors were encountered: