我正在尝试制作一个按钮,按下该按钮即可启动游戏。在它显示let pointOfTouch = touch.location(self)
的地方,我收到错误消息“无法调用非函数类型的值'CGFloat。'”对此有another post,但我没有从中找到太多用处。这是我的代码:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch: AnyObject in touches {
let pointOfTouch = touch.location(self)
let nodeITapped = atPoint(pointOfTouch)
if nodeITapped.name == "startGame" {
startGame()
}
}
}
答案 0 :(得分:0)
你可以尝试
let pointOfTouch = touch.location(in: self)