ios - 如何使用 iOS SpriteKit 在环形内强制触摸?

标签 ios swift sprite-kit collision-detection

我需要让玩家在阴影环内移动手指: enter image description here

一旦手指移出环(以红色显示),程序应该能够检测到“越界”事件。

在 SpriteKit 中,最好是在 Swift 中,有什么最佳实践吗?谢谢!

最佳答案

您可以使用 CGPath 绘制形状, 然后使用 CGPathContainsPoint以确定触摸的位置是在路径内部还是外部。

您可以使用 SKShapeNode 在 SpriteKit 中像这样使用 CGPaths| .

关于ios - 如何使用 iOS SpriteKit 在环形内强制触摸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34836590/

相关文章:

ios - 为什么我会收到 fatal error : unexpectedly found nil while unwrapping an Optional value when trying to go to mapView?

ios - 获取 UIBezierPath IOS 的面积和周长

ios - 初始化器中的局部参数标签命名约定

swift - NSUserNotification 的属性 additionalActions 似乎不起作用?

ios - Sprite Kit-使用Switch Case将随机的Sprite节点添加到场景中

ios - 随机运动/湍流 - SWIFT

ios - SpriteKit 物理 : How to make a player sprite follow the (sloped) ground

ios - 库缓存路径中 iOS 应用程序 Cache.db 的用途是什么?

macos - Swift 中的 OS X 应用程序 View 管理

iOS - 防止重复将事件添加到日历