SpriteKit SKPhysicsBody破坏了碰撞 [英] SpriteKit SKPhysicsBody broken collisions

查看:290
本文介绍了SpriteKit SKPhysicsBody破坏了碰撞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SKSpriteNode ,它有一个静态正文,由凹路径生成,带有 edgeChainFromPath 。我们将此节点称为 house

I have a SKSpriteNode which has a static body, generated from concave path with edgeChainFromPath. Let's call this node a house.

我还有另一种 SKSpriteNode s它有一个动态方体,用 rectangleOfSize 生成。我们将此节点称为

I also have another kind of SKSpriteNodes which have a dynamic square body, generated with rectangleOfSize. Let's call this node a box.

在我的场景中,被抛出,又被冲进房子,因为他们都有尸体,应该与房子发生碰撞并反弹。

In my scene, the boxes are thrown aka impulsed into the house and since both of them have bodies, the boxes should collide with the house and bounce away.

我正在滚动场景,因此创建了上面描述的完全相同的 house 的新实例。

I'm scrolling the scene and therefore creating new instances of EXACTLY THE SAME house described above.

问题我的意思是某些房屋完全或部分地破坏了碰撞。一些房屋完全碰撞,有些与仅在身体的某些随机区段碰撞,有些完全忽略与

The problem I'm having is that collisions are completely or partially broken for some houses. Some houses collide with boxes exactly as they should, some collide with boxes only on some random segments of the body, and some completely ignore collisions with the boxes.

此问题仅发生在iPad上,而不会发生在iPhone上。在iPad模拟器和真正的iPad设备上都会发生。

This problem only happens on iPad and never on iPhone. Happens both on iPad Simulator and real iPad device.

问题完全随机发生在随机房屋上。

The problem occurs completely random and on random houses.

我还尝试使用 edgeLoopF​​romPath 创建 house 正文,但问题仍然存在。

I also tried creating house body with edgeLoopFromPath but the problem remains.

另外,我正在绘制物理学,可以看到 house 的物理主体完全正确。

Also, I'm drawing the physics and can see that the physics body of the house is exactly as it should be.

对于值得讲述的场景或节点没有什么特别之处。

There is nothing else special about the scene or nodes that would be worth telling about.

我正在使用 SpriteKit Swift in iOS 9

I'm using SpriteKit with Swift in iOS 9.

更新

似乎问题在于设置房屋的规模节点。我必须这样做,以便在所有屏幕尺寸上具有通用外观。

Seems like the issue is in setting the scale on house nodes. I have to do that in order to have universal look on all screen sizes.

仍在寻找解决方案/解决方法......

Still looking for solution/workaround...

推荐答案

这可能是因为edgeLoopF​​romPath创建了一个带有边缘的空心框,而不是带有边的边框。

This is likely due to edgeLoopFromPath creating a hollow box with an edge for your house, not one with volume.

我会尝试使用 bodyWithPolygonFromPath 以及向盒子和房屋添加exactCollisionDetection。

I would try using bodyWithPolygonFromPath as well as adding preciseCollisionDetection to both your boxes and houses.

这篇关于SpriteKit SKPhysicsBody破坏了碰撞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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