/ Published in: Objective C
motion of objects(labels and images)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#define SIGN(x) ((x < 0.0f) ? -1.0f : 1.0f) float yaccel, yvelocity; - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ float yy = acceleration.y; float accelDirY = SIGN(yvelocity) * -1.0f; float newDirY = SIGN(yy); if (accelDirY == newDirY) yvelocity = -yaccel * yy; }