Quote:
Originally Posted by smithdale87
Looks to me like you're missing an ending '}' at the end of your accelerometer method in the .m
|
You are def right that I was missing that bracket. I put it in and still getting errors.
These are my new errors:
1. Expected "(" before 'fabs'
2. Request for member 'x' in something not a structure or union
3. Request for member 'y' in something not a structure or union
4. Request for member 'value' in something not a structure or union
5. Expected ':' before '{' token
is my method written correctly for "makeBallDisappear" ?
is this a sufficient declaration in the .h file or do I need to put in the method parameters?
-(void)makeBallDisappear;
#import "AccelViewController.h"
#import "Math.h"
@implementation AccelViewController
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
valueX = acceleration.x*40.0;
valueY = acceleration.y*40.0;
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 newY = (int)(ball.center.y - valueY);
if (newY > 460-BALL_RADIUS)
newY =460-BALL_RADIUS;
if (newY <0+BALL_RADIUS)
newY = 0+BALL_RADIUS;
CGPoint newCenter = CGPointMake(newX, newY);
ball.center = newCenter;
valueA = acceleration.x*17.0;
valueB = acceleration.y*17.0;
int newA = (int)(ball2.center.x +valueA);
if (newA > 320-BALL_RADIUS)
newA = 320-BALL_RADIUS;
if (newA< 0+BALL_RADIUS)
newA = 0+ BALL_RADIUS;
int newB = (int)(ball2.center.y -valueB);
if (newB > 460-BALL_RADIUS)
newB =460-BALL_RADIUS;
if (newB <0+BALL_RADIUS)
newB = 0+BALL_RADIUS;
CGPoint aNewCenter = CGPointMake(newA, newB);
ball2.center = aNewCenter;
}
-(void)makeBallDisappear
{
if fabs(redhole.x-ball.valueX < RHOLE_RADIUS-BALL_RADIUS)
&&
fabs(redhole.y-ball.valueY < BHOLE_RADIUS-BALL_RADIUS)
{
[view ball.visible = NO];
}
}