JavaWizKid

Oct 19, 2009, 05:14 PM

I've coded this:

- (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?

- (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?