I extended SKSpriteNode with my own class to have more features.
But how can I get this extended node when the βhitsβ of this node and didBeginContact ?
Since contact.bodyA and contact.bodyB are physical, and the parent is a game scene.
This is my subclass of SKSpriteNode:
class Orange: SKSpriteNode { ... func createPhysicsBody(){ self.physicsBody = SKPhysicsBody(circleOfRadius: self.size.width / 2) self.physicsBody?.dynamic = true ... } }
This is my didBeginContact code:
func didBeginContact(contact: SKPhysicsContact){ switch(contact.bodyA.categoryBitMask + contact.bodyB.categoryBitMask){ case orangeCategory + bulletCategory: contactOrangeBullet(contact.bodyA, bodyB: contact.bodyB) break; default: break; } }
In contactOrangeBullet there is only code that processes everything when this happens. But I need more than physicsBody . I need an βorangeβ, which physicsBody is just a part of.
Or do I understand something is wrong, and this is impossible, because the physics of Body does not adhere to the "orange", although it was created there?
source share