Return to Snippet

Revision: 37407
at December 9, 2010 18:25 by vaishnavi


Initial Code
#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)
		yaccel = (abs(yaccel) + 0.99f) * SIGN(yaccel);

	yvelocity = -yaccel * yy;	
}

Initial URL

                                

Initial Description
motion of objects(labels and images)

Initial Title
implementing accelerometer to move objects

Initial Tags

                                

Initial Language
Objective C