|
1 | 1 | import React, { Component, PropTypes } from 'react'; |
2 | 2 | import { observer } from 'mobx-react'; |
3 | | -import Gamepad from 'html5-gamepad'; |
4 | 3 | import Matter from 'matter-js'; |
5 | 4 |
|
6 | 5 | import { |
|
9 | 8 | Sprite, |
10 | 9 | } from '../../src'; |
11 | 10 |
|
12 | | -const gamepad = new Gamepad(); |
13 | | - |
14 | 11 | @observer |
15 | 12 | export default class Character extends Component { |
16 | 13 |
|
@@ -88,26 +85,26 @@ export default class Character extends Component { |
88 | 85 |
|
89 | 86 | let characterState = 2; |
90 | 87 |
|
91 | | - if (keys.isDown(65) || gamepad.button(0, 'b')) { |
| 88 | + if (keys.isDown(65)) { |
92 | 89 | return this.punch(); |
93 | 90 | } |
94 | 91 |
|
95 | | - if (keys.isDown(keys.SPACE) || gamepad.button(0, 'a')) { |
| 92 | + if (keys.isDown(keys.SPACE)) { |
96 | 93 | this.jump(body); |
97 | 94 | } |
98 | 95 |
|
99 | | - if (keys.isDown(keys.UP) || gamepad.button(0, 'button 12')) { |
| 96 | + if (keys.isDown(keys.UP)) { |
100 | 97 | return this.enterBuilding(body); |
101 | 98 | } |
102 | 99 |
|
103 | | - if (keys.isDown(keys.LEFT) || gamepad.button(0, 'button 14')) { |
| 100 | + if (keys.isDown(keys.LEFT)) { |
104 | 101 | if (shouldMoveStageLeft) { |
105 | 102 | store.setStageX(store.stageX + 5); |
106 | 103 | } |
107 | 104 |
|
108 | 105 | this.move(body, -5); |
109 | 106 | characterState = 1; |
110 | | - } else if (keys.isDown(keys.RIGHT) || gamepad.button(0, 'button 15')) { |
| 107 | + } else if (keys.isDown(keys.RIGHT)) { |
111 | 108 | if (shouldMoveStageRight) { |
112 | 109 | store.setStageX(store.stageX - 5); |
113 | 110 | } |
@@ -139,8 +136,6 @@ export default class Character extends Component { |
139 | 136 | } |
140 | 137 |
|
141 | 138 | if (!this.isJumping && !this.isPunching && !this.isLeaving) { |
142 | | - gamepad.update(); |
143 | | - |
144 | 139 | this.checkKeys(shouldMoveStageLeft, shouldMoveStageRight); |
145 | 140 |
|
146 | 141 | store.setCharacterPosition(body.position); |
|
0 commit comments