I made a game where I need to cast the touched SKSpriteNode into a custom class. It works perfectly fine on the iOS 9.1 simulator but it cannot seem to cast at all in the iOS 8.4 simulator.
In iOS 9.1, my class is an MyCustomClass type but in iOS 8.4 it is a SKSpriteNode. Nothing else is changed, only the simulator OS.
I set the custom class directly in Xcode in the SpriteKit GameScene (I click on the node and use the right tab to enter "MyCustomClass" in the "Custom Class" section). I tried adding the project name as in "Project.MyCustomClass" but this has no effect.
If you have a solution, I would love to know it!
if self.nodeAtPoint(location).isKindOfClass(MyCustomClass) {
print("Is my class") //This is the result in iOS 9.1
}else if self.nodeAtPoint(location).isKindOfClass(SKSpriteNode){
print("Is an SKSPriteNode") //This is the result in iOS 8.4
}else if self.nodeAtPoint(location).isKindOfClass(SKNode) {
print("Is an SKNode")
}
if let touchedNode = self.nodeAtPoint(location) as? Objet {
//Fails on iOS 8.4 but succeed in iOS 9.1
}
Thanks for your time.
PS: I am using Xcode 7.1.1.