Sha256: 34ba24ee5b4483aa130e5f2ecd1ce2cda5fe191b4f7fb2becec50242c6a58d3f
Contents?: true
Size: 979 Bytes
Versions: 25
Compression:
Stored size: 979 Bytes
Contents
// Thanks for inspiration to Phil Cooper-King. // This is adapted from his MIT-licensed Gosu fork // on GitHub. #import <GosuImpl/Input/AccelerometerReader.hpp> @implementation AccelerometerReader - (AccelerometerReader*)initWithUpdateInterval: (float)updateInterval { if (self = [super init]) { [[UIAccelerometer sharedAccelerometer] setUpdateInterval: updateInterval]; [[UIAccelerometer sharedAccelerometer] setDelegate:self]; acceleration[0] = acceleration[1] = acceleration[2] = 0.0f; } return self; } - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)uiAccel { float factor = 0.3f; acceleration[0] = (uiAccel.x * factor) + (acceleration[0] * (1 - factor)); acceleration[1] = (uiAccel.y * factor) + (acceleration[1] * (1 - factor)); acceleration[2] = (uiAccel.z * factor) + (acceleration[2] * (1 - factor)); } - (const Acceleration&)acceleration { return acceleration; } @end
Version data entries
25 entries across 25 versions & 1 rubygems