Swift: Cannot convert value of type ViewController to expected argument type SKNode

650 Views Asked by At

I'm implementing and extension of my viewController and implementing SpriteKit scene in the extension. But I'm getting an error touchesBegan function. This is my implementation:

import UIKit
import SpriteKit

extension ViewController{

    func makeScene() -> SKScene {

        let scene = SKScene.init(size: CGSize(width:view.frame.width-50,height:view.frame.height-50))
        scene.backgroundColor = .black
        return scene
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let  touch = touches.first
        firstPoint = touch!.locationInNode(self)
    }
}

On this line firstPoint = touch!.locationInNode(self) I'm getting this error:

Cannot convert value of type ViewController to expected argument type SKNode

Any of you knows why I'm getting this error? or if there is any workaround this error?

I'll really appreciate your help.

0

There are 0 best solutions below