我知道如何在 gamescene.sks 中做到这一点——你只需要选择一个 Sprite 并选中 body 类型形式的“alpha mask”。 但是如何以编程方式进行呢?我担心我对 .sks 的操作会以失败告终。所以我想通过快速代码来完成。我查看了物理体相关的方法和属性,但没有发现任何接近“alpha mask”的东西
最佳答案
您没有找到任何与 alpha 相关的内容?可能想仔细看看... bodyWithTexture:size:
的文档说(强调):
Use this method when your sprite has a shape that you want replicated in its physics body... A new physics body is created that includes all of the texels in the texture that have a nonzero alpha value.
另见 bodyWithTexture:alphaThreshold:size:
如果您想更改 alpha 阈值。
关于ios - SpriteKit : How to make physics body of a sprite to copy an actual image?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28840907/