Game Development Reference
In-Depth Information
There are also no special steps required for building or deploying our application,
even on Android, where any code written in Java needs to be supplied in a JAR file.
The deployment tool will automatically add any required extension files to the install
package without us having to do a thing.
Example code
The following sections detail the code samples that accompany this chapter.
The Gyroscope project
This project contains the complete source code for the Gyroscope extension
developed throughout the course of this chapter. Compiled versions of the
extension have also been included so you can build the other example projects
for this chapter without having to first build the extension itself.
The GyroTest project
The GyroTest project is a simple example that makes use of the Gyroscope extension.
It demonstrates how to include the Gyroscope extension into a project, how to
check if the extension is available, and then how to call the extension function if it
is available.
The sample will be displayed on screen whether or not gyroscope support is
available. If it is, the raw gyroscope values will also be displayed on screen.
The Skiing project
Our final update to the Skiing project sees it make use of the Gyroscope extension
developed in this chapter as another possible control method.
As with the other input methods in the game, a class called GyroscopeManager has
been created, which wraps up the Gyroscope extension. This then keeps all use of
the extension functions in a single source file, which makes it easier to update should
we ever change the API of the extension in any way.
No matter how still the device is, even if left lying on a stable surface, the gyroscope
values will always have a certain amount of jitter. The GyroscopeManager class deals
with this by maintaining a filtered version of the gyroscope inputs that are used to
control the skier in the game.
 
Search WWH ::




Custom Search