- Joined
- May 6, 2017
- Messages
- 270
- Reaction score
- 110
- First Language
- Italian
- Primarily Uses
- RMMV
Ok so this thread is partially related to this one (about the use of multiple gamepads): simply put, I'm trying to solve it myself editing "Input.isPressed".
Here's the original code:
Here's mine:
When I test my project, it doesn't crash, but it works only when the "else if" condition is true; when the condition is false, it doesn't crash, it simply always returns false (since I'm using 4 gamepads, "gamepadNumber" is always between 0 and 3).
Here's the original code:
Code:
/**
* Checks whether a key is currently pressed down.
*
* @static
* @method isPressed
* @param {String} keyName The mapped name of the key
* @return {Boolean} True if the key is pressed
*/
Input.isPressed = function(keyName) {
if (this._isEscapeCompatible(keyName) && this.isPressed('escape')) {
return true;
} else {
return this._currentState[keyName];
}
};
Code:
Input.isPressed = function(keyName, gamepadNumber) {
if (this._isEscapeCompatible(keyName) && this.isPressed('escape')) {
return true;
} else if (gamepadNumber == undefined) {
return this._currentState[keyName];
} else {
return this._gamepadStates[gamepadNumber][keyName];
}
};
