ios - 有没有一种简单的方法可以从图像中绘制 SKnodes 障碍物的坐标?

标签 ios swift sprite-kit game-physics ios-universal-app

我正在创建一个游戏,我需要根据级别(背景图像)在(SKNodes)中绘制一些障碍。 假设我有一棵树,我想在它周围绘制边框,如下图所示:

enter image description here

我需要坐标来创建物理主体。

有没有简单的方法呢? (也许是一个软件?)

我需要为不同的设备调整相同的坐标,因此我认为手动执行此操作太复杂。

有什么想法吗?

谢谢!

最佳答案

有一个 SKPhysicsBody 类方法可以提供帮助:

+ bodyWithTexture:size:

来自描述:

Use this method when your sprite has a shape that you want replicated in its physics body. The texture is scaled to the new size and then analyzed. A new physics body is created that includes all of the texels in the texture that have a nonzero alpha value. The shape of this body attempts to strike a good balance between performance and accuracy. For example, fine details may be ignored if keeping them would cause a significant performance penalty.

关于ios - 有没有一种简单的方法可以从图像中绘制 SKnodes 障碍物的坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30097053/

相关文章:

ios - 使用 HCYoutubeParser 播放 YouTube 视频

c++ - windows/osx/ipad 上的跨平台 GUI

ios - HKObserverQuery 后台传递在调用completionHandler 后停止工作

Swift SpriteNode 初始角度

ios - SKLabelNode 将消失但仍可点击

android - 将本地存储从 Cordova 应用迁移到 Android 应用

ios - 多次使用 Text 时,SwiftUI 上没有更多上下文,表达式类型不明确,如何解决?

swift - 如何解释错误。谢谢

ios - Swift iOS 如何在本地存储自定义类型对象?

ios - Swift:在相机边界外包裹/循环/重复节点?