I've coded this:
and for some reason it doesn't execute the negative commands? Any suggestions as to what is wrong?
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?