export class LossAnimation { // sinBoxCenter: { x, y } screen position of the Sin fund box play(scene, originX, originY, sinBoxCenter, onComplete) { // Pick a random demon sprite (frames 0–5) const frame = Phaser.Math.Between(0, 5); const demon = scene.add.sprite(originX, originY, 'demon_sprites', frame) .setOrigin(0.5, 0.5); // Screen tint to dark red briefly scene.cameras.main.flash(800, 150, 0, 0, true); // Play a random no-match voice line scene.sound.play(`sfx-nomatch-${Phaser.Math.Between(1, 6)}`); // Travel from slot machine to sin box scene.tweens.add({ targets: demon, x: sinBoxCenter.x, y: sinBoxCenter.y, duration: 2800, ease: 'Cubic.easeInOut', onComplete: () => { scene.tweens.add({ targets: demon, alpha: 0, duration: 600, onComplete: () => { demon.destroy(); if (onComplete) onComplete(); } }); } }); // Rock counter-clockwise and clockwise while travelling scene.tweens.add({ targets: demon, angle: { from: -8, to: 8 }, duration: 400, yoyo: true, repeat: 6 }); } }