Fixed issues with pipe rotation on mouse out
This commit is contained in:
parent
a4efa5b68a
commit
759b70733a
|
|
@ -357,18 +357,31 @@ export default class PipePuzzleGame extends Phaser.Scene {
|
|||
}
|
||||
|
||||
// ── Interaction ────────────────────────────────────────────────────────────
|
||||
// Kill only the tweens on `target` that animate the given property names.
|
||||
// Phaser 3.90's `killTweensOf(target, 'prop')` no longer supports the
|
||||
// prop filter — the argument is silently ignored and EVERY tween on the
|
||||
// target is destroyed (which is what let a pointerout kill a tile's
|
||||
// in-flight rotation tween, freezing it mid-spin).
|
||||
_killTweensOf(target, ...props) {
|
||||
const want = new Set(props);
|
||||
for (const t of this.tweens.getTweensOf(target)) {
|
||||
if (t.data && t.data.some((d) => want.has(d.key))) t.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
_setHover(i, on) {
|
||||
if (this._screen !== 'play' || this._won) return;
|
||||
const base = this._cellBaseScale;
|
||||
if (on) {
|
||||
this._hover = i;
|
||||
this._cells[i].setInteractive({ useHandCursor: true });
|
||||
this._killTweensOf(this._cells[i], 'scaleX', 'scaleY');
|
||||
this.tweens.add({ targets: this._cells[i], scaleX: base * 1.06, scaleY: base * 1.06, duration: 120, ease: 'Quad.easeOut' });
|
||||
} else {
|
||||
if (this._hover === i) this._hover = null;
|
||||
// Always restore this tile's scale — pointerout can land before the
|
||||
// neighbor's pointerover, so don't rely on _hover being current.
|
||||
this.tweens.killTweensOf(this._cells[i], 'scaleX');
|
||||
this._killTweensOf(this._cells[i], 'scaleX', 'scaleY');
|
||||
this.tweens.add({ targets: this._cells[i], scaleX: base, scaleY: base, duration: 140, ease: 'Quad.easeOut' });
|
||||
}
|
||||
}
|
||||
|
|
@ -384,7 +397,7 @@ export default class PipePuzzleGame extends Phaser.Scene {
|
|||
|
||||
const img = this._cells[i];
|
||||
img._targetAngle += 90;
|
||||
this.tweens.killTweensOf(img, 'angle'); // only the spin — leave hover-scale tweens alone
|
||||
this._killTweensOf(img, 'angle'); // only the spin — leave hover-scale tweens alone
|
||||
this.tweens.add({
|
||||
targets: img,
|
||||
angle: img._targetAngle,
|
||||
|
|
|
|||
Loading…
Reference in New Issue