Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Sprite Kit Collision with movement through elements

Tags:

ios

iphone

sprite

Is it possible to use Sprite kit's physicsBody to have element collision and still allow elements to go through each other? I'm interested in having the delegate to be called only when two borders hit each other and then allow them to go through each other afterwards :)

like image 440
eagle Avatar asked Feb 04 '26 09:02

eagle


1 Answers

Yes this is possible. You can register for callbacks from collisions between objects but not have the collision affect the object itself.

The Ray Wenderlich - Sprite Kit book explains how to do this in the Zombie Conga game tutorial.

Try this one... http://www.raywenderlich.com/42699/spritekit-tutorial-for-beginners

The section called "Collision Detection and Physics: Implementation" should explain what you need.

Just had a quick read and the two things you're after are...

contactTestBitMask this is which object collisions you want to receive collision callbacks for. collisionBitMask this is which object will collide and "bounce" off each other.

like image 183
Fogmeister Avatar answered Feb 06 '26 21:02

Fogmeister