Skip to Content
Windows® Phone 8 Unleashed
book

Windows® Phone 8 Unleashed

by Daniel Vaughan
May 2013
Intermediate to advanced
1152 pages
82h 34m
English
Sams
Content preview from Windows® Phone 8 Unleashed

Shake Detection

The phone SDK does not come with any built-in support for detecting when the device is being shaken. This section extends the custom EnhancedAccelerometer to provide shake detection.

The EnhancedAccelerometer.IsShake method returns true if the difference between the current and previous acceleration readings exceeds a threshold value for two or more dimensional components, in which case, the movement is deemed a shake. Thanks to Mark Monster, http://bit.ly/9GMDJX, on which this code is based. See the following excerpt:

static bool IsShake(Vector3 currentAcceleration,                    Vector3 previousAcceleration, double threshold){    double deltaX = Math.Abs(previousAcceleration.X - currentAcceleration.X); ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Windows® Phone 7.5 Unleashed

Windows® Phone 7.5 Unleashed

Daniel Vaughan
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Windows Phone 8 Development Internals

Windows Phone 8 Development Internals

Andrew Whitechapel and Sean McKenna

Publisher Resources

ISBN: 9780133383959Purchase book