2014-09-18 50 views
0

当我写误差的touchesBegan代码

@implementation GameViewController 

-(IBAction)StartGame:(id)sender{ 

    StartGame.hidden = YES; 

    BirdMovement = [NSTimer scheduledTimerWithTimeInterval:0.05 
    target:self selector:@selector(BirdMoving) userInfo:nil repeats:YES]; 

} 

-(void)BirdMoving{ 

    Bird.center = CGPointMake(Bird.center.x, Bird.center.y - BirdFlight); 

    BirdFlight = BirdFlight - 5; 

    if (BirdFlight < -15) { 
     BirdFlight = -15; 

     if (BirdFlight > 0) { 
      Bird.image = [UIImage imageNamed:@"3.png"]; 

     } 

     if (BirdFlight < 0) { 
      Bird.image = [UIImage imageNamed:@"4.png"]; 
     } 

} 


-(void)touchesBegan:(NSSet *)touches withEvent: (UIEvent *)event{ 

    BirdFlight =30; 

} 

它说,我用一个未声明的标识符touchesBegan: 请帮我:)

+0

您需要将您的代码缩进四个空格,以便在stackoverflow上正确地格式化它。 – 2014-09-18 21:09:11

回答

0

你忘了关闭右括号(})在if (BirdFlight < -15)声明你的BirdMoving方法。 (或按A)。然后选择Editor> Structure> Re-Indent(或按控制I)。这会让问题变得明显。