[P3] Fix Substitute visual error on wave transition (#4648)

This commit is contained in:
innerthunder 2024-10-12 21:46:41 -07:00 committed by GitHub
parent 391f38c3c8
commit 470f9e4e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -749,9 +749,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const relX = newOffset[0] - initialOffset[0];
const relY = newOffset[1] - initialOffset[1];
const subTag = this.getTag(SubstituteTag);
if (duration) {
// TODO: can this use stricter typing?
const targets: any[] = [ this ];
if (subTag?.sprite) {
targets.push(subTag.sprite);
}
this.scene.tweens.add({
targets: this,
targets: targets,
x: (_target, _key, value: number) => value + relX,
y: (_target, _key, value: number) => value + relY,
duration: duration,
@ -761,6 +768,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
} else {
this.x += relX;
this.y += relY;
if (subTag?.sprite) {
subTag.sprite.x += relX;
subTag.sprite.y += relY;
}
}
});
}