iOS Sprite Kit Collision with movement through elements

心不动则不痛 提交于 2020-02-15 08:30:59

问题


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 :)


回答1:


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.



来源:https://stackoverflow.com/questions/22019951/ios-sprite-kit-collision-with-movement-through-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!