From 4057fbf84672cd96cfc22645e3ebd213b7037ca9 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 15 Apr 2024 19:44:30 -0400 Subject: [PATCH] Formatting consistency changes --- src/battle-scene.ts | 26 ++++++++++++-------------- src/main.ts | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 2d732992773..15f5f3c6f09 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -215,7 +215,7 @@ export default class BattleScene extends SceneBase { [Button.CYCLE_NATURE]: 2, // square [Button.SPEED_UP]: 10, // L3 [Button.SLOW_DOWN]: 11 // R3 - } + }; public gamepadButtonStates: boolean[] = new Array(17).fill(false); public rngCounter: integer = 0; @@ -1299,24 +1299,22 @@ export default class BattleScene extends SceneBase { * again. */ gamepadButtonJustDown(button: Phaser.Input.Gamepad.Button) : boolean { + if (!button) + return false; - if (!button) return; + let ret = false; + if (button.pressed) { + if (!this.gamepadButtonStates[button.index]) + ret = true; + this.gamepadButtonStates[button.index] = true; + } else + this.gamepadButtonStates[button.index] = false; - let returnValue = false; - if (button.pressed) { - if (!this.gamepadButtonStates[button.index]) { - returnValue = true; - } - this.gamepadButtonStates[button.index] = true; - } else { - this.gamepadButtonStates[button.index] = false; - } - - return returnValue; + return ret; } buttonJustPressed(button: Button): boolean { - const gamepad = this.input.gamepad?.gamepads[0]; + const gamepad = this.input.gamepad?.gamepads[0]; return this.buttonKeys[button].some(k => Phaser.Input.Keyboard.JustDown(k)) || this.gamepadButtonJustDown(gamepad?.buttons[this.gamepadKeyConfig[button]]); } diff --git a/src/main.ts b/src/main.ts index 8695ffb34f5..13aa5076ff4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -44,7 +44,7 @@ const config: Phaser.Types.Core.GameConfig = { touch: { target: 'app' }, - gamepad: true + gamepad: true }, dom: { createContainer: true