嘿,我有一个很好的代码,它是@Sam_M 给我的。
我试图在移动时基本上跟踪多个手指的位置。就像手指 1 在这里,手指 2 在那里一样。因此,截至目前,它将打印当前在视图和位置上的手指/触摸数量,但不会分别跟踪两个单独的手指。我环顾了 stackoverflow 上仅有的 3 个其他问题。但没有一个给我一个好的结果,我可以快速实现。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: UITouch in event!.allTouches()! {
for (index,touch) in touches.enumerate() {
let ptTouch = touch.locationInNode(self.view)
print("Finger \(index+1): x=\(pTouch.x) , y=\(pTouch.y)")
}
}
Run Code Online (Sandbox Code Playgroud)
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch: UITouch in event!.allTouches()! {
for (index,touch) in touches.enumerate() {
let ptTouch = touch.locationInNode(self.view)
print("Finger \(index+1): x=\(pTouch.x) , y=\(pTouch.y)")
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个SCNNode完整的工作物理体附加到它,但物理体中心/静止点位于 的底部SCNNode。
这就是我想做的:
Apple Developer 到目前为止还没有帮助我。这是我所拥有的:
let nodePhysicsBody = SCNPhysicsBody(type: .dynamic, shape: SCNPhysicsShape(geometry: SCNCapsule(capRadius: 2.0, height: 2.0), options: nil))
Run Code Online (Sandbox Code Playgroud)
我找到了这个 init 方法,但我不确定它是否有效,或者如何实现它。
.init(circleOfRadius r: CGFloat, center: CGPoint()
Run Code Online (Sandbox Code Playgroud)