获得"使用未声明的标识符"意味着什么?错误? (Xcode9 /目标-C)

时间:2017-11-11 23:48:23

标签: ios objective-c xcode

在Xcode(Objective-C)中,我收到以下错误:

 "Use of undeclared identifier 'touchesBegan' "

错误显示在 E (不在实际代码中)

这意味着什么,我该怎么做才能解决它?

我正在使用Xcode 9 IOS 11.0进行简单的游戏。

我很乐意接受任何帮助。

谢谢。

这是我的代码:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { *E*
[super touchesBegan:touches withEvent:event];

static const NSTimeInterval kHugeTime = 9999.0;
SKNode *ball = [self childNodeWithName:@"ball"];


for (UITouch *touch in touches) {
    if([touch locationInNode:ball.parent].x < ball.position.x){
        leftTouches++;
    }}
    else{
        rightTouches++;
}
}

if((leftTouches == 1) && (rightTouches == 0)){
        //Move Ball Left
    SKAction *leftMove = [SKAction moveBy:CGVectorMake(-1.0*kMoveSpeed*kHugeTime,0) duration:(kHugeTime)];
    [ball runAction:leftMove withKey:@"Action"];
}
else if((leftTouches == 0) && (rightTouches == 1)){
        //Move Ball Right
    SKAction *rightMove = [SKAction moveBy:CGVectorMake(1.0*kMoveSpeed*kHugeTime,0) duration:(kHugeTime)];
    [ball runAction:rightMove withKey:@"Action"];
}
else if((leftTouches + rightTouches) > 1){
        //Jump
    SKAction *jumpMove = [SKAction applyImpulse:CGVectorMake(0, 2500) duration:0.4];
    [ball runAction:jumpMove withKey:@"Action"];
} 
} @end

0 个答案:

没有答案