我正在制作一个简单的游戏,Xcode 发现一个错误说存在“使用未声明的标识符'gameLoop'”。我怎样才能解决这个问题?
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
(void)viewDidLoad {
[super viewDidLoad];
gameState = kStateRunning;
[NSTimer scheduledTimerWithTimeInterval: 1.0/60 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
rockVelocity = CGPointMake (0, 0);
gravity = CGPointMake (0, kGravity);
- (void)gameLoop {
if (gameState == kStateRunning)
{
[self gameStatePlayNormal];
}
else if (gameState == kStateGameOver)
{
}
}
(void)gameStatePlayNormal {
rockVelocity.y += gravity.y;
rock.center = CGPoint(rock.center.x + ballVelocity.x,rock.center.y + rockVelocity.y);