it says 'gameLoop' undeclared. can anyone correct this please?
(void) gameLoop {
if(gameState == kGameStateRunning) {
playerScoreText.hidden = YES;
computerScoreText.hidden = YES;
winOrLoseLabel.hidden = YES;
ball.center = CGPointMake(ball.center.x + ballVelocity.x , ball.center.y + ballVelocity.y);
if(ball.center.x > self.view.bounds.size.width || ball.center.x < 0) {
ballVelocity.x =- ballVelocity.x;
}
if(ball.center.y > self.view.bounds.size.height || ball.center.y < 0) {
ballVelocity.y =- ballVelocity.y;
}
if (CGRectIntersectsRect (ball.frame, playerPaddle.frame)) {
CGRect frame = ball.frame;
frame.origin.x = playerPaddle.frame.origin.x - frame.size.height;
ball.frame = frame;
ballVelocity.x =- ballVelocity.x;
开发者_高级运维 }
Have you declared the gameLoop method in your source header file? If you haven't, calling the gameLoop method from another class or from the same class (earlier on in the file) could cause this problem.
So you'd add this to your header file:
- (void)gameLoop;
For bonus points: If gameLoop is 'private' to your class (i.e. other classes don't need to call it) you could declare it in an empty 'extension' category at the top of the .m file.
精彩评论