Game Development Reference
In-Depth Information
NOTE
I highly suggest checking out a library called Hand.js which is a polyfill for supporting
pointer events on every browser. You can learn more about the project here . What is great
about this library is that you simply code to the Pointer events and it works on everything
from desktop to mobile devices, including iOS and Android without needing to worry
about what the capabilities of the device are. You get pointer events with IDs if there is
multi-touch and just like MSPointer outlined above, you can detect if it was a mouse, pen
or touch.
Working with Controllers and Game Pads
One of the key advantages of building a game for Windows 8 is the ability to access physical
hardware via the USB ports. Of course the first thing that may come to mind is how do I get
my game to work with an Xbox controller or other compatible USB gamepad? While WinJS
doesn't directly expose access to the Windows 8 controller API, we will go over how to ac-
cess this via the C++ bridge that allows JavaScript to communicate with the underlying OS.
In order to get started, we are going to need to download this library , which abstracts the
Windows 8 C++ controller API and exposes it to JavaScript.
NOTE
For more information on how the underlying Windows 8 controller API works, make sure
to read this .
To get started, copy over the cpp folder to the project and click on Solution and Add Existing
Project.
As you can see in Figure 4-2 , we have added the GameController project to our Visual Stu-
dio solution. Now we need to sort out any dependencies between the two projects. You can
do this by opening up the Project Dependencies window.
Search WWH ::




Custom Search