Anicet Posted October 27, 2017 Share Posted October 27, 2017 Hi, I am trying to make a menu which lets the user bind the in-game inputs. But I have no idea how to do that... Maybe there is a way to detect which input he presses and then use this information when creating input... Thanks beforehand. Link to comment Share on other sites More sharing options...
Andy R Posted October 29, 2017 Share Posted October 29, 2017 Hello, I would do something like that : -> set a callback to the "onkeypress" event, this function will detect which key was pressed and then call the associated action -> in the user cookies, make a hash keycode=>event (eg: A is 'move_left') -> then in your callback function when you detect A you know that the user wants to 'move_left' of course when your user want to change his bindings you have to change the cookie too Hope it helps Link to comment Share on other sites More sharing options...
Anicet Posted October 30, 2017 Author Share Posted October 30, 2017 Thanks Andy, but my question really was how to do your onkeypress callback thing. In fact I'm a beginer with phaser and I don't know the syntax for this one Link to comment Share on other sites More sharing options...
samme Posted October 30, 2017 Share Posted October 30, 2017 Can be done with Keyboard#addCallbacks, e.g., game.input.keyboard.addCallbacks(console, console.log); // Now hit some keys and look in the console But I'd save this work for later. First get your game working with just one set of keys. Link to comment Share on other sites More sharing options...
Anicet Posted October 31, 2017 Author Share Posted October 31, 2017 I was just planning on the paper all the in-game features so I wanted to know if it is possible. Now I get it ! Thanks ! Link to comment Share on other sites More sharing options...
Recommended Posts