Swift, SpriteKit: Drawing with an SKTexture

Discussion in 'iOS Programming' started by Milese3, Sep 4, 2014.

  1. Milese3 macrumors 6502

    Aug 11, 2014
    Southampton - United Kingdom
    Hi, I would like to know how I can use the TouchesMoved function in Swift to draw an SKTexture (in my case, a ladder texture) where the user drew.

    King regards, Miles.
  2. omenatarhuri, Sep 8, 2014
    Last edited by a moderator: Sep 8, 2014

    omenatarhuri macrumors 6502a

    Feb 9, 2010

    Something like this should work?

    override func touchesMoved(touches: NSSet, withEvent event: UIEvent)
            for touch: AnyObject in touches
                let location = touch.locationInNode(self)
    func drawMyAwesomeLadder(location : CGPoint)
              var newNode = SKSpriteNode(texture: SKTexture(imageNamed: "ladder"))
            newNode.position = location
            view.addChild(newNode) // view here is your SKView
    Oops, it was 4 days ago, I suppose you solved it already. :)

Share This Page