Initial commit: Naddie Jump — Monad Edition
This commit is contained in:
23
src/entities/Spring.js
Normal file
23
src/entities/Spring.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Physics } from 'phaser';
|
||||
import { SUPER_JUMP_VELOCITY } from '../config/game.config.js';
|
||||
|
||||
export class Spring extends Physics.Arcade.Sprite {
|
||||
constructor(scene, x, y) {
|
||||
super(scene, x, y, 'spring');
|
||||
scene.add.existing(this);
|
||||
scene.physics.add.existing(this, true);
|
||||
|
||||
this.setScale(1);
|
||||
this.body.setSize(20, 32);
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
onPlayerTouch(player) {
|
||||
if (!this.active) return false;
|
||||
this.active = false;
|
||||
this.setVisible(false);
|
||||
this.body.enable = false;
|
||||
player.jump(SUPER_JUMP_VELOCITY);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user