制作条件TapGestureRecognizer?

时间:2015-09-15 09:04:14

标签: ios swift uitapgesturerecognizer

如果用户在球击中地面后点击屏幕,我想返回我的初始场景。我如何制作一个条件语句,以便我可以点击屏幕返回主页?

func didBeginContact(contact: SKPhysicsContact) {
    if ( contact.bodyA.categoryBitMask & groundCategory ) == groundCategory || ( contact.bodyB.categoryBitMask & groundCategory ) == groundCategory {   //Ball hits ground
        //Return to home screen if you tap the screen after the game ends
        gameEnded = true
    }
}

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
     if gameEnded {
          //How do I restart my Game?
     }
}

0 个答案:

没有答案