更改SKPhysicsBody的身体形状 [英] Change a SKPhysicsBody's body shape

查看:153
本文介绍了更改SKPhysicsBody的身体形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了定义SKPhysicsBody形状的主体之外,我什么都不想更改.我该怎么做?

I don't want to change ANYTHING other than the body that defines the shape of a SKPhysicsBody. How do I do this?

我似乎找不到可以更改此设置的地方.

I can't seem to find where I can change this.

甚至是有关如何更改它的评论.

Or even commentary on how to change it.

是的,我知道这必须谨慎进行,以免发生所有可能的新碰撞,重叠等.但是,撇开这些,我该如何更改SKPhysicsBody的主体?

Yes, I know this has to be done carefully, so that it avoids all possible new collisions, overlaps, etc. But putting that aside, how do I change the body of an SKPhysicsBody?

推荐答案

您可以使用CGMutablePath手动为物理物体创建自定义形状,然后将其传递到SKPhysicsBody构造函数中.

You can manually create a custom shape for a physics body using CGMutablePath, then pass it into the SKPhysicsBody constructor.

例如:

let path = CGMutablePath()
path.move(to: CGPoint(.....))
path.addLine(to: CGPoint(.....))

let customPhysicsBody = SKPhysicsBody(edgeChainFrom: path)

这篇关于更改SKPhysicsBody的身体形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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