我正在尝试从我的场景中删除/删除一个开始按钮,当我点击它时,该按钮变得不可见但我仍然可以点击它并重新启动我的场景...任何解决方案吗?
这是我的代码:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches{
let location = touch.location(in: self)
if startButton.contains(location){
restartScene()
}
if died == true {
if restartButton.contains(location){
restartScene()
}
}
}
startingGame()
}
func restartScene() {
self.removeAllChildren()
self.removeAllActions()
died = false
gameStarted = false
score = 0
createScene()
}
func createScene() {
self.physicsWorld.contactDelegate = self
createGround()
createBird1()
createBackground()
displayScoreLabel()
}
我已经发现它与这一行有关:
let location = touch.location(in: self)
我不希望这是一个位置而是SKSpritenode,任何解决方案? 我仍然很快乐,所以任何帮助都会非常感激!!