我在Xcode中遇到NSTimer问题

时间:2013-08-20 03:51:50

标签: nstimer cgpoint game-loop

我在Xcode上制作一个简单的游戏,我决定在我的.m中使用一个nstimer xcode在我的代码中发现了三个问题:分配到' CGPoint' (又名' struct CGPoint')来自可兼容的' int'两次,它说使用未声明的游戏循环。任何帮助都很棒

@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)
    {

    }
}

1 个答案:

答案 0 :(得分:1)

你需要说     CGPointMake(0,0); 您还需要确保通过说

在头文件中声明gameLoop函数
-(void)gameLoop;

您的viewDidLoad也缺少结束括号。在NSTimer方法之后添加一个。