Fix Substitute visual error on wave transition

This commit is contained in:
innerthunder 2024-10-12 00:59:38 -07:00
parent cfb92b4e08
commit 1e85a575ce

View File

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