Hiya! I’m trying to map a controller to be used in my game. I’m currently trying to make it work with my menu system, which can usually be navigated using WASD, arrow keys and the enter key. I want to add the d-pad and the B button to that list.
I ran into a problem where the .on()
function is not recognised. I checked the documentation again and the function is there:
https://photonstorm.github.io/phaser3-docs/Phaser.Input.Gamepad.Gamepad.html#on__anchor
Here’s the error that I get
And here is the code that is associated with that error:
let pad = Phaser.Input.Gamepad.Gamepad;
if (this.input.gamepad.total){
pad = this.input.gamepad.getPad(0);
}
pad.on('buttonDown', pad =>{
switch (pad) {
case up:
this.activeText -= 1;
this.events.emit('CHANGE_BUTTON');
break;
case down:
this.activeText += 1;
this.events.emit('CHANGE_BUTTON');
break;
case B:
this.events.emit('SELECT');
break;
}
});
Please take a look and feel free to give me any advice on how to fix it Thank you!