Game Development Reference
In-Depth Information
Locking on with a GPS
Although we know how to find the orientation of the device, we don't really know
where it is in the world. This is where the GPS sensor comes into play. The GPS
sensor (if installed) provides the latitude and longitude location of the machine, which
we can use to determine where the device is and enable games that take advantage
of that information.
Many games can use this information to provide a rich experience to the player, from
augmented reality games through to spatial games that require you to be in certain
physical locations. The increase in mobile platforms (phones and tablets) means that
there has been an increase in this style of game, and as this is such a new occurrence
there isn't a defined type of game or genre that can take advantage of this.
WinRT has a GPS API that allows for quick and easy access to your location;
however, you need to remember that this functionality is limited by a location capab-
ility, which the user can opt out of for privacy reasons. To request this capability from
the operating system, you need to set the Location capability in the application mani-
fest, as shown in the screenshot that follows:
The operating system will handle seeking permission from the user to use their loca-
tion, so you just need to check that box and confirm if you have the permission when
you need it.
Similar to the sensors discussed earlier, there are two different ways to get access to
the information: events and polling. Unlike the sensors, however, there isn't a GetDe-
fault() method that gives you the one instance of the sensor. This means you need
to create and maintain a reference to a Geolocator object that will handle the GPS
functionality.
Search WWH ::




Custom Search