Keep SKNodes from applying force to each other

我是研究僧i 提交于 2019-12-02 09:29:12

You can achieve that by setting category, collision and contact bit masks.

uint32_t bodyABitMask = 1<<0;
uint32_t bodyBBitMask = 1<<1;

//A mask that defines which categories this physics body belongs to.
[bodyA setCategoryBitMask:bodyABitMask];
[bodyB setCategoryBitMask:bodyBBitMask];

//A mask that defines which categories of physics bodies 
//can collide with this physics body.
[bodyA setCollisionBitMask:0];
[bodyB setCollisionBitMask:0];

//A mask that defines which categories of bodies cause 
//intersection notifications with this physics body.
[bodyA setContactTestBitMask:bodyBBitMask];
[bodyB setContactTestBitMask:bodyABitMask];

In above case bodyA and bodyB cannot collide, but you will receive didBeginContact once they are in contact.

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