Diego Esc Diego Esc - 1 year ago 107
Swift Question

Add nodes where touches began

I´m making a game with Swift.
I need to add nodes where I press the screen, I know this is not from other planet but I can't do it.

Answer Source

Highly simplified example could look like this:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    guard let touch = touches.first else { return }
    let location = touch.location(in: self)
    let node = SKNode()
    node.position = location
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download