【发布时间】:2023-03-15 15:25:01
【问题描述】:
我正在尝试创建一个切换场景的按钮。我知道切换场景的代码,但我用来通过按钮执行此操作的代码不起作用。
更新:我的代码在第一个场景上工作,但是当我在另一个场景上使用相同的代码时(我切换了按钮和场景)它不起作用。 有人知道为什么吗?
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let gamestartScene = GameStartScene(size: self.frame.size)
var location = CGPoint(x: 0, y: 0)
var touch = touches.anyObject() as UITouch
location = touch.locationInView(self.view)
if menuButton.containsPoint(location){
self.removeChildrenInArray([menuButton,replayButton,highScoreLabel,scoreLabela])
self.view?.presentScene(gamestartScene)
score = 0
}
}
【问题讨论】:
-
寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现它所需的最短代码。跨度>
标签: ios swift compiler-errors sprite-kit