blob: d452d1a0e7b2a5f7642474799da5e38ca9938976 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { Direction } from './Direction';
import type { BattleEngine } from './BattleEngine';
import type { AkkamonMenu } from '../scenes/UIElement';
export class BattleControls {
private cursors: Phaser.Types.Input.Keyboard.CursorKeys;
constructor(
private input: Phaser.Input.InputPlugin,
private menu: AkkamonMenu,
) {
this.cursors = this.input.keyboard.createCursorKeys();
}
update() {
if (Phaser.Input.Keyboard.JustDown(this.cursors.left)) {
console.log("left");
this.menu.selectButton(Direction.LEFT);
} else if (Phaser.Input.Keyboard.JustDown(this.cursors.right)) {
console.log("right");
this.menu.selectButton(Direction.RIGHT);
} else if (Phaser.Input.Keyboard.JustDown(this.cursors.up)) {
console.log("up");
this.menu.selectButton(Direction.UP);
} else if (Phaser.Input.Keyboard.JustDown(this.cursors.down)) {
console.log("down");
this.menu.selectButton(Direction.DOWN);
} else if (Phaser.Input.Keyboard.JustDown(this.cursors.space)) {
console.log("confirm");
this.menu.confirm();
}
}
}
|