refact round
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
import Phaser from "phaser";
|
||||
import { ObstacleSpikeBase } from "./ObstacleSpikeBase";
|
||||
|
||||
export class ObstacleSpikeTricky extends Phaser.GameObjects.Image {
|
||||
export class ObstacleSpikeTricky extends ObstacleSpikeBase {
|
||||
static readonly TEXTURE_KEY = "spike-tricky";
|
||||
static readonly WIDTH = 40;
|
||||
static readonly HEIGHT = 20;
|
||||
static readonly TRIGGER_DISTANCE = 55;
|
||||
static readonly DISPLACEMENT = 100;
|
||||
|
||||
declare body: Phaser.Physics.Arcade.StaticBody;
|
||||
|
||||
private moved = false;
|
||||
|
||||
constructor(scene: Phaser.Scene, x: number, y: number) {
|
||||
super(scene, x, y, ObstacleSpikeTricky.TEXTURE_KEY);
|
||||
scene.add.existing(this);
|
||||
scene.physics.add.existing(this, true);
|
||||
}
|
||||
|
||||
react(playerX: number): void {
|
||||
react(playerX: number, _playerY: number): void {
|
||||
if (this.moved) return;
|
||||
const dx = this.x - playerX;
|
||||
if (Math.abs(dx) < ObstacleSpikeTricky.TRIGGER_DISTANCE) {
|
||||
|
||||
Reference in New Issue
Block a user