Reputation: 10940
Im dragging a SKSpriteNode around with the following method
override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
for touch in touches {
let location = touch.locationInNode(self)
var touchedNode = nodeAtPoint(location)
if touchedNode.isKindOfClass(Card) {
touchedNode.position = location
}
}
}
the if statement is confirming that it;s pif a specific class, how can I now call methods and access properties this node?
Upvotes: 0
Views: 461
Reputation: 40874
You can use this syntax:
if let cardNode = touchedNode as Card {
cardNode.position = location
// cardNode is of type card. You can access all its
// methods and properties
}
Upvotes: 1