Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Adding Tilt with the Virtual Accelerometer Object

Part of the HTML5 Game Development For Dummies Cheat Sheet

An HTML5 game programmer can use an accelerometer (the Accel object) to read tilt and movement input on supported devices, such as tablets and phones.

accelName = new Accel() Creates a new Accel object called accelName.
getAX() Returns rotation around the X axis as a –1 to 1 value (often used to modify DY).
getAY() Returns rotation around the Y axis as a –1 to 1 value (often used to modify DX).
getAZ() Returns rotation around the Z axis (rotating the device like a steering wheel). Typically, the getAY() also returns suitable values for this type of input, so getAZ() is rarely needed.
getRotX(), getRotY(), getRotZ() Returns the current change in rotation around each of the axes. Normally, the get() methods are more useful.
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!