I’m encountering an issue when creating spawning notes. They’re not synchronized, and I’m unsure how to address this problem. I could use some assistance.
Here are my codes:
update(time, delta) {
const deltaSeconds = delta / 1000;
elapsedTime += deltaSeconds;
if (elapsedTime >= this.beatDuration) {
beatCount++;
elapsedTime -= this.beatDuration;
this.metronome.play();
this.scoreText.setText(`Beat Count: ${beatCount}`);
this.spawnNote();
}
}
spawnNote() {
const finalRadius = 2000;
this.circle = new Phaser.Geom.Circle(1200 / 2, 700 / 2, 10);
this.path = this.add.graphics({
lineStyle: {
width: 5,
color: 0xffffff
}
});
this.tweens.add({
targets: this.circle,
radius: finalRadius,
duration: 4000,
ease: 'Linear',
onComplete: () => {
this.path.clear();
this.tweens.remove(this);
},
onUpdate: () => {
this.path.clear();
this.path.strokeCircleShape(this.circle);
}
});
}