简体   繁体   English

有没有办法在SpriteKit中创建凹形PhysicsBody?

[英]Is there a way to create a concave physicsBody in SpriteKit?

I have an object on scene and my hero should not go through it, but it should be able to go inside of it, like a boat into the bay, surrounded by the other element. 我在场景中有一个物体,我的英雄不应该穿过它,但是它应该能够在它内部进入,就像一条进入海湾的船,被其他元素包围。 I tried all kinds of physicsBody having it have body with rectangle, texture, with polygon from path, but to no avail. 我尝试了各种PhysicsBody,使其具有矩形,纹理,路径中具有多边形的身体,但无济于事。 I was reading somewhere that it is not possible to have a concave physicsBody, but only convex. 我在某个地方读到,不可能有凹入的物理体,而只有凸出的。 I really need it to be able to be concave. 我真的需要它能够凹进去。 Does anyone know how to resolve this? 有谁知道如何解决这个问题?

You can create a concave physics body by adding up a bunch of convex physics bodies into one shape. 您可以通过将一堆凸形物理物体合为一个形状来创建凹形物理物体。 Then you can add them as children to an SKNode so that they stick together. 然后,您可以将它们作为子代添加到SKNode,以便它们粘在一起。 there are some physics editor apps that can help you do this so you arent writing a bunch of coordinates by hand. 有一些物理学编辑器应用程序可以帮助您完成此任务,因此您无法手动编写一堆坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM