Contact bitmask for multiple SpriteKit nodes

Hey ,



I have learned how to use categorie bitmask and contact bitmask and these things but I found one issue that I seek if someone can solve it if it can be solved 



What if I have 50 SpriteKit nodes that each of them has a different categorybitmask and I have a ball if the ball collided with one of those 50 SpriteKit nodes it for example change the color of the the collided SpriteKit to for example blue 



To achieve this I know I have to write the category bitmask of the SpriteKit node in contact bitmask of the ball



The question is what if if I have 50 SpriteKit nodes how can I or do I have to write all of the 50 SpriteKit nodes in the contact bitmask of the ball



I tried using a loop but I didn’t know how to implement it right 



And thanks for your help

Replies

There are only 32 bits in the bitmask. These bits are for allowing types of contact, or contact between types of nodes. You should use just one of the bits for all these balls. The contact test delegate will get called for each pair of nodes. In the contact test delegate, examine the ball node and make the changes you need.