How do I detect if an SKSpriteNode has been touched

First set the name property of the SKSpriteNode to a string. pineapple.name = “pineapple” pineapple.userInteractionEnabled = false then in touchesBegan function in the Scene override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touch:UITouch = touches.anyObject()! as UITouch let positionInScene = touch.locationInNode(self) let touchedNode = self.nodeAtPoint(positionInScene) if let name = touchedNode.name { if name == … Read more

Swift – Must call a designated initializer of the superclass SKSpriteNode error

init(texture: SKTexture!, color: UIColor!, size: CGSize) is the only designated initializer in the SKSpriteNode class, the rest are all convenience initializers, so you can’t call super on them. Change your code to this: class Creature: SKSpriteNode { var isAlive:Bool = false { didSet { self.hidden = !isAlive } } var livingNeighbours:Int = 0 init() { … Read more