IPHONE SDK, How to put Void function into my BOOL??? PLEASE!
Posted
by Harry
on Stack Overflow
See other posts from Stack Overflow
or by Harry
Published on 2010-03-25T20:44:24Z
Indexed on
2010/03/25
21:13 UTC
Read the original article
Hit count: 376
I am using the IPhone's Accelerometer to make a object move. I want to be able to make this function work and not work depending on different states.
I have my code for my Accelerometer function and i want to put it into a BOOL so i can call on it when i need it, but i am having problems. Can anyone Help me put this code into a BOOL named:
-(BOOL) accelerometerWorks
-(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
valueX = acceleration.x*25.5;
int newX = (int)(ball.center.x +valueX);
if (newX > 320-BALL_RADIUS)
newX = 320-BALL_RADIUS;
if (newX < 0+BALL_RADIUS)
newX = 0+BALL_RADIUS;
int XA = (int)(balloonbit1.center.x +valueX);
if (XA > 320-BALL_RADIUS)
XA = 320-BALL_RADIUS;
if (XA < 0+BALL_RADIUS)
XA = 0+BALL_RADIUS;
int XB = (int)(balloonbit2.center.x +valueX);
if (XB > 320-BALL_RADIUS)
XB = 320-BALL_RADIUS;
if (XB < 0+BALL_RADIUS)
XB = 0+BALL_RADIUS;
int XE = (int)(balloonbit5.center.x +valueX);
if (XE > 320-BALL_RADIUS)
XE = 320-BALL_RADIUS;
if (XE < 0+BALL_RADIUS)
XE = 0+BALL_RADIUS;
int XF = (int)(balloonbit6.center.x +valueX);
if (XF > 320-BALL_RADIUS)
XF = 320-BALL_RADIUS;
if (XF < 0+BALL_RADIUS)
XF = 0+BALL_RADIUS;
int XH = (int)(balloonbit8.center.x +valueX);
if (XH > 320-BALL_RADIUS)
XH = 320-BALL_RADIUS;
if (XH < 0+BALL_RADIUS)
XH = 0+BALL_RADIUS;
ball.center = CGPointMake (newX, 415);
balloonbit1.center = CGPointMake (XA, 408);
balloonbit2.center = CGPointMake (XB, 395);
balloonbit5.center = CGPointMake (XE, 388);
balloonbit6.center = CGPointMake (XF, 413);
balloonbit8.center = CGPointMake (XH, 426);
}
Please help. i have been trying for ages with no success. Thanks. Harry.
© Stack Overflow or respective owner