Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Sprite Kit PhysicsBody,检查两个身体是否相互接触_Ios_Iphone_Sprite - Fatal编程技术网

Ios Sprite Kit PhysicsBody,检查两个身体是否相互接触

Ios Sprite Kit PhysicsBody,检查两个身体是否相互接触,ios,iphone,sprite,Ios,Iphone,Sprite,在精灵套件中,我能检测到两个身体是否互相接触吗?有代表吗?。我对didBeginContact或DiEndContact不感兴趣,因为我需要这两者之间的某种联系:) 现在我已经有了这个代码 - (void)didBeginContact:(SKPhysicsContact *)contact { self.contactWithEnemy = YES; } - (void)didEndContact:(SKPhysicsContact *)contact { self.cont

在精灵套件中,我能检测到两个身体是否互相接触吗?有代表吗?。我对didBeginContact或DiEndContact不感兴趣,因为我需要这两者之间的某种联系:)

现在我已经有了这个代码

- (void)didBeginContact:(SKPhysicsContact *)contact
{
    self.contactWithEnemy = YES;
}

- (void)didEndContact:(SKPhysicsContact *)contact
{
    self.contactWithEnemy = NO;

}

-(void)update:(CFTimeInterval)currentTime {
    if(self.contactWithEnemy == YES) {
      if([_tusk actionForKey:@"punch"]) {
        NSLog(@"HIT");
    }
}
}


但从这里开始,我将如何应对我“击中”的目标

您提到现有的委托方法是
didBeginContact
didEndContact
。您可以使用这两种方法设置和取消设置指示触摸的标志,并且可以在需要时查询其状态

是的,这是可能的


大约一个小时前,我在这里为您回答了:)

请不要重复两个问题。我的错误福格迈斯特:/无需担心:D只是在这里保持清楚:D我实际上在认出您的帐户之前回答了这个问题阿凡达:事实上,这不是他的另一个问题的重复。请检查我的更新:)现在完全有意义了。我还没想到:s。谢谢