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