M Milese3 macrumors 6502 Original poster Aug 11, 2014 301 34 Southampton - United Kingdom Sep 4, 2014 #1 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.
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.
O omenatarhuri macrumors 65816 Feb 9, 2010 1,058 1,124 Sep 8, 2014 #2 Hey, Something like this should work? Code: override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { for touch: AnyObject in touches { let location = touch.locationInNode(self) drawMyAwesomeLadder(location) } } 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. Last edited by a moderator: Sep 8, 2014
Hey, Something like this should work? Code: override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { for touch: AnyObject in touches { let location = touch.locationInNode(self) drawMyAwesomeLadder(location) } } 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.