Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is hit and how much hitpoints it has.
Problem: I had several approaches from extending SKSpriteNode
or SKPhysicsBody
but all failed. SKSpriteNode doesn't work, because Swifts collision detection only returns physicsBody and since you can't extend physicsBody, it didn't work to save there ships attributes as well.
Question: What would be a good approach to save such data to my game objects? I do not need code - because I think I can write it myself - but I would be happy to read a good suggestion. But if you have already some code written and a good solution for this problem, I would not be angry to read it ;)
SKNode
, how come that didn't work for you ? This answer definitely seems correct. I suppose you have to cast thephysicsBody.node
instance toOrange
(as long asOrange
extendsSKNode
). \$\endgroup\$