JeZxLee Posted July 28, 2017 Share Posted July 28, 2017 Hi, Alpha3 Final is live and people are complaining about input. I am basically doing input myself, but perhaps using PixiJS would be better? Does PixiJS handle input, if yes can you point me to a code example, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 28, 2017 Author Share Posted July 28, 2017 I talk of keyboard input... What would be the best way to handle keyboard input in a PixiJSv4 game? document.addEventListener("keypress", CheckForKeyPress, true); document.addEventListener("keydown", CheckForKeyDown, true); document.addEventListener("keyup", CheckForKeyRelease, true); Is the above OK, or I need to do something different? function CheckForKeyDown(evt) { if (DelayAllUserInput === 0) { if (evt.keyCode === 8) KeyboardCharacterPressed = "="; else if (evt.keyCode === 13) KeyboardCharacterPressed = "/"; else if (evt.keyCode === 27) KeyboardCharacterPressed = "~"; else if (evt.keyCode === 32) KeyboardCharacterPressed = " "; if (evt.keyCode === 38) JoystickDirection/*.Vertical*/ = UP; else if (evt.keyCode === 39) JoystickDirection/*.Horizontal*/ = RIGHT; else if (evt.keyCode === 40) JoystickDirection/*.Vertical*/ = DOWN; else if (evt.keyCode === 37) JoystickDirection/*.Horizontal*/ = LEFT; if (evt.keyCode === 90) JoystickButtonOne = ON; else if (evt.keyCode === 88) JoystickButtonTwo = ON; } } Quote Link to comment Share on other sites More sharing options...
mattstyles Posted July 29, 2017 Share Posted July 29, 2017 That's one way yes, and it would certainly work, although it gives a precedence to keypresses, which might be unacceptable. For example, if you hit right and up at the same time (which can happen if you're trying to change direction quickly) then up will always win as you've introduced precedence by using if..else clauses. This might be fine for you, otherwise you'll have to be a bit smarter about how you handle your inputs. Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 29, 2017 Author Share Posted July 29, 2017 All is ok, we fixed the input issue, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.