Closed nhmbounteous closed 4 years ago
Hi @nhmbounteous,
The game engine provides provides both onKeyDown
and onKeyUp
events. Here is a list of all the provided events:
onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onWheel onTouchCancel onTouchEnd onTouchMove onTouchStart onKeyDown onKeyPress onKeyUp
Using these basic events, you can create a variety of controllers similar to what you descibed. Here is a basic keyboard controller that is wrapped into a system.
Let me know if that helps!
@bberak I was suggesting on implementing a similar controller utility. I think I understand the point of using the default events. However, do you think it would be worth developing utility systems?
@nhmbounteous I wouldn't be inclined to make them part of the core project because in my experience every game/app will have slightly different needs.
However, I would totally understand if someone created and distributed a library of common systems that can be plugged into react-game-engine
. That is kind of where I was going with the react-game-engine-template project. The template repo contains a bunch of utilities and systems I use over and over in my personal projects (but they might not be suitable for everyone).
Sounds good, thank you for the responsiveness :D
No problems @nhmbounteous, more than happy to chat about this stuff!
There is a lag with the onKeyPress events in browsers. I would suggest creating a object that contains valid input keys. onKeyDown load that key into the object as true and onKeyUp set the key to false.