Code:
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.gameState = kGameStatePaused;
pucVelocity = CGPointMake(kPucSpeedX,KPucSpeedY);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
}
-(void) gameLoop {
if(gameState == kGameStateRunning) {
puc.center = CGPointMake(puc.center.x + pucVelocity.x , puc.center.y + pucVelocity.y);
if(puc.center.x > self.view.bounds.size.width || puc.center.x < 0) {
pucVelocity.x = -pucVelocity.x;
}
if(puc.center.y > self.view.bounds.size.height || puc.center.y < 0) {
pucVelocity.y = -pucVelocity.y;
}
} else {
if (tapToBegin.hidden) {
tapToBegin.hidden = NO;
}
}
if (CGRectIntersectsRect(puc.frame,paddleblue.frame)) {
if(puc.center.y < paddleblue.center.y) {
pucVelocity.y = -pucVelocity.y;
NSLog(@"%f %f",puc.center,paddlegreen.center);
}
}
if (CGRectIntersectsRect(puc.frame,paddlegreen.frame)) {
if(puc.center.y > paddlegreen.center.y) {
pucVelocity.y = -pucVelocity.y;
}
}
//Begin AI
if (puc.center.y <= self.view.center.y) {
if(puc.center.x < paddlegreen.center.x) {
CGPoint compLocation = CGPointMake(paddlegreen.center.x - kCompMoveSpeed, paddlegreen.center.y);
paddlegreen.center = compLocation;
}
if(puc.center.x > paddlegreen.center.x) {
CGPoint compLocation = CGPointMake(paddlegreen.center.x + kCompMoveSpeed, paddlegreen.center.y);
paddlegreen.center = compLocation;
} //End AI
}
} //End of GameLoop
Again, the line the error comes up in is highlighted in red.