我在 Xcode 上制作了一个简单的游戏,我决定在我的 .m xcode 中使用 nstimer 发现我的代码有 3 个问题,它说从兼容的“int”中分配给“CGPoint”(又名“struct CGPoint”)两次,它说使用未声明的游戏循环。任何帮助都很棒
@implementation ViewController
@synthesize bg, rock, platform1, platform2, platform3, platform4, platform5, platform6, platform7;
@synthesize gameState;
@synthesize rockVelocity, gravity;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
gameState = kStateRunning;
rockVelocity = CGpointMake (0, 0);
gravity = CGpointMake (0, kGravity);
[NSTimer scheduledTimerWithTimeInterval: 1.0/60 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
- (void)gameLoop {
if (gameState == kStateRunning)
{
[self gameStatePlayNormal];
}
else if (gameState == kStateGameOver)
{
}
}