Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JavaWizKid

macrumors 6502a
Original poster
Sep 18, 2008
572
1
I've coded this:
Code:
- (void)accelerometer:(UIAccelerometer *)acel didAccelerate:(UIAcceleration *)aceler {
	
	if (fabsf(aceler.x) > 0.5)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipMovingrX,kSpaceshipY);
	}
	if (fabsf(aceler.x) <= 0.5 && fabsf(aceler.x) >= 0)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipX,kSpaceshipY);
	}
	if (fabsf(aceler.x) < -0.5)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipMovinglX,kSpaceshipY);
	}
	if (fabsf(aceler.x) >= -0.5 && fabsf(aceler.x) <= 0)
	{
		spaceshipVelocity = CGPointMake(kSpaceshipX,kSpaceshipY);
	}
}

and for some reason it doesn't execute the negative commands? Any suggestions as to what is wrong?
 
I meant a way to get negative values because tilting one way and only one way seems a bit pointless :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.