有没有办法在SpriteKit中创建凹形PhysicsBody? [英] Is there a way to create a concave physicsBody in SpriteKit?

查看:131
本文介绍了有没有办法在SpriteKit中创建凹形PhysicsBody?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在场上有一个物体,我的英雄不应该穿过它,但它应该能够像进入船上的船一样被其他元素所包围,进入它的内部.我尝试了各种PhysicsBody,使其具有矩形,纹理,路径中具有多边形的主体,但无济于事.我在某个地方读到,不可能有凹入的物理体,而只有凸出的.我真的需要它能够凹进去.有人知道如何解决这个问题吗?

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. 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?

推荐答案

您可以通过将一堆凸形物理体合为一个形状来创建凹形物理体.然后,您可以将它们作为子代添加到SKNode,以便它们粘在一起.有一些物理学编辑器应用程序可以帮助您完成此任务,因此您无法手动编写一堆坐标.

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. there are some physics editor apps that can help you do this so you arent writing a bunch of coordinates by hand.

这篇关于有没有办法在SpriteKit中创建凹形PhysicsBody?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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