SKPhysicsJoint:联系人和碰撞无法正常工作 [英] SKPhysicsJoint: Contacts and collisions not working

查看:137
本文介绍了SKPhysicsJoint:联系人和碰撞无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IOS7.1上,使用SpriteKit,我创建了两个带有相应物理实体的简单矩形精灵。我设置了接触和碰撞位掩码,所有工作完全符合我的预期:检测到接触并且碰撞阻止两个矩形重叠。但是当我创建一个SKPhysicsJointSpring对象并加入两个矩形时,即使矩形有时在模拟过程中重叠,也没有检测到任何接触。 (弹簧行为的效果与人们预期的一样,可见振荡。)

On IOS7.1, using SpriteKit, I've created two simple rectangular sprites with corresponding physics bodies. I set up contact and collision bit masks, and all works exactly as I expect: contacts are detected and collisions prevent the two rectangles from overlapping. But when I create an SKPhysicsJointSpring object and join the two rectangles, no contacts are ever detected even though the rectangles sometimes overlap during simulation. (The spring behavior works just as one would expect, though, with visible oscillations.)

换句话说,加入物理机构似乎可以防止SprikeKit中的接触检测和碰撞,这不是我想要的行为。

In other words, joining physics bodies seems to prevent contact detection and collisions in SprikeKit, which is not the behavior I desire.

任何人都知道有什么方法可以解决这个问题吗?谢谢。

Anyone know of any way to fix this? Thanks.

推荐答案

没有修复,这是Box2D物理引擎Sprite Kit使用的内置行为。当您通过关节连接两个实体时,它们不再接触并且不会相互碰撞。

There is no fix, this is built-in behavior of the Box2D physics engine Sprite Kit uses. When you connect two bodies through a joint, they no longer contact and do not collide with each other.

使用Box2D,您可以通过 collideConnected 标志。但是Sprite Kit的物理类中没有这样的标志。

With Box2D you can change this behavior via the collideConnected flag. However no such flag exists in Sprite Kit's physics classes.

这篇关于SKPhysicsJoint:联系人和碰撞无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆