Coins: collectible dropped in clusters (lines/arcs) above platforms; collected on overlap, banked into a persistent wallet at game over, shown in HUD and on the GameOver screen. Magnet power-up pulls nearby coins toward the player for 6s (HUD duration bar). Gas Limit shield power-up grants a cyan aura that absorbs one enemy hit instead of dying, then breaks. New procedural textures (coin/magnet/shield), spawn weights, durations, sound, and stats (coins collected, GWEI wallet) wired through ScoreManager/StatsManager/Settings. Verified via in-browser sim: coins spawn, magnet pull 100px to 10px, collect increments GWEI, shield absorbs a hit (no game over) while no shield = death.
34 lines
898 B
JavaScript
34 lines
898 B
JavaScript
import { Physics } from 'phaser';
|
|
|
|
export class Magnet extends Physics.Arcade.Sprite {
|
|
constructor(scene, x, y) {
|
|
super(scene, x, y, 'magnet');
|
|
scene.add.existing(this);
|
|
scene.physics.add.existing(this, true);
|
|
|
|
this.setScale(0.8);
|
|
this.body.setSize(this.width * 0.8, this.height * 0.8);
|
|
this.body.setOffset(this.width * 0.1, this.height * 0.1);
|
|
this.consumed = false;
|
|
|
|
this.floatTween = scene.tweens.add({
|
|
targets: this, y: y - 6, duration: 700, yoyo: true, repeat: -1, ease: 'Sine.easeInOut',
|
|
});
|
|
}
|
|
|
|
onPlayerTouch(player) {
|
|
if (this.consumed) return false;
|
|
this.consumed = true;
|
|
this.body.enable = false;
|
|
this.setVisible(false);
|
|
player.startMagnet();
|
|
this.destroy();
|
|
return true;
|
|
}
|
|
|
|
destroy(fromScene) {
|
|
if (this.floatTween) { this.floatTween.stop(); this.floatTween = null; }
|
|
super.destroy(fromScene);
|
|
}
|
|
}
|