Browse code

fix gamepad button menu controls iteraction

devnewton authored on 08/03/2018 16:20:52
Showing 2 changed files
... ...
@@ -24,16 +24,16 @@ export class GamepadOptions extends AbstractState {
24 24
         subtitle.y = this.game.world.height - subtitle.height;
25 25
 
26 26
         const menu = new Menu(this.game);
27
-        menu.add(new GamepadMenuButton(this.input.gamepad.pad1, 0xFF6666, "Gamepad 1", 200, 100, () => {
27
+        menu.addButton(new GamepadMenuButton(this.input.gamepad.pad1, 0xFF6666, "Gamepad 1", 200, 100, () => {
28 28
             this.game.state.start('GamepadOptionsLayout', true, false, 1);
29 29
         }));
30
-        menu.add(new GamepadMenuButton(this.input.gamepad.pad2, 0x66FF66, "Gamepad 2", 200, 200, () => {
30
+        menu.addButton(new GamepadMenuButton(this.input.gamepad.pad2, 0x66FF66, "Gamepad 2", 200, 200, () => {
31 31
             this.game.state.start('GamepadOptionsLayout', true, false, 2);
32 32
         }));
33
-        menu.add(new GamepadMenuButton(this.input.gamepad.pad3, 0x6666FF, "Gamepad 3", 200, 300, () => {
33
+        menu.addButton(new GamepadMenuButton(this.input.gamepad.pad3, 0x6666FF, "Gamepad 3", 200, 300, () => {
34 34
             this.game.state.start('GamepadOptionsLayout', true, false, 3);
35 35
         }));
36
-        menu.add(new GamepadMenuButton(this.input.gamepad.pad4, 0xFFFF66, "Gamepad 4", 200, 400, () => {
36
+        menu.addButton(new GamepadMenuButton(this.input.gamepad.pad4, 0xFFFF66, "Gamepad 4", 200, 400, () => {
37 37
             this.game.state.start('GamepadOptionsLayout', true, false, 4);
38 38
         }));
39 39
         menu.button("Back", 200, 550, () => this.game.state.start('Options'));
... ...
@@ -17,6 +17,10 @@ export class Menu extends Phaser.Group {
17 17
         game.add.existing(this);
18 18
     }
19 19
 
20
+    addButton(button: MenuButton) {
21
+        this.buttons.add(button);
22
+    }
23
+
20 24
     button(label: string, x: number, y: number, callback: Function) {
21 25
         this.buttons.add(new MenuButton(this.game, label, x, y, callback));
22 26
     }