Using the motion sensors
In this recipe we will look into how to use the accelerometer and gyroscope.
Getting ready
Open PSM Studio and create a new project, adding references for GameEngine2D
and GameEngine2D.Base
. The complete code for this recipe is available at Ch2_Example5
.
This example will not run in the simulator. Some Android based devices may not support the gyro, so AngularVelocity
may not be available.
How to do it...
Open AppMain.cs
and enter the following code:
using System; using System.Collections.Generic; using Sce.PlayStation.Core; using Sce.PlayStation.Core.Environment; using Sce.PlayStation.Core.Graphics; using Sce.PlayStation.Core.Input; using Sce.PlayStation.HighLevel.GameEngine2D; using Sce.PlayStation.HighLevel.GameEngine2D.Base; ...
Get PlayStation®Mobile Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.