Search code examples
swift3skphysicsbodyskphysicscontact

SKSpritNode no contact with other bodies?


I would like to create a game with multiple contact options but I need to find also condition when sprite is not with contact with any other body.

I don't want to be informed that sprite is losing contact like with didEnd function.

I need information that sprite has no contact at all...

How to do that?

Thank you


Solution

  • you can use mySprite.physicsBody?.allContactedBodies() to get array of bodies that are in contact with your sprite. Then you can simply find out what bodies are not in contact with your sprite by excluding members of this array from all bodies.