-2
我正在做一個簡單的遊戲,Xcode發現一個錯誤說有一個「使用未聲明的標識符'gameLoop'」。我怎樣才能解決這個問題?在Xcode中使用未聲明的標識符
// 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);
感謝現在它說,使用未申報的viewDidLoad – user2514477
的你需要說 - (無效)viewDidLoad中,而不是(無效)viewDidLoad中 –
你會看起來像PS感謝 – user2514477