I have the Circle object that extends shape and am trying to get the value of x or position of the object in 2d plane. During animation (tween) the position does not update and remains static. How do i fix this ?
export class Circle extends Phaser.GameObjects.Shape {
tween;
constructor(scene:Phaser.Scene, x, y) {
super(scene);
let enemy = scene.add.circle(x, y, 20);
enemy.setStrokeStyle(1, 0x05F9FB);
this.tween = scene.tweens.add({
targets: enemy,
x: 560,
y: 200,
ease: 'Power1',
duration: 3000,
yoyo: true,
repeat: -1
});
}
}
I have the below method in update method and it always returns original x value not the update one during tween.
update() {
//Always returns the orginal position of x and not the updated or current state of x
console.log(enemy.x);
}