无法调用非函数类型'CGFloat'的值 - Xcode -

时间:2018-03-28 20:36:30

标签: ios swift xcode

我正在尝试制作一个按钮,按下该按钮即可启动游戏。在它显示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()
        }
    }
}

1 个答案:

答案 0 :(得分:0)

你可以尝试

let pointOfTouch = touch.location(in: self)