在SceneKit(Swift)中点击/选择节点 [英] Tap / Select Node in SceneKit (Swift)
问题描述
我是iOS中的SceneKit和3D空间的新手。我目前正在制作一个简单的游戏,显示一个28段的立方体(如果你愿意,可以使用迷你立方体)。
I'm new to SceneKit and 3D spaces in iOS. I'm currently working on a simple game that shows a cube of 28 segments ("mini cubes" if you want).
我想通过点击移动迷你立方体他们,但我无法理解如何选择特定节点(大立方体的子节点)。
I want to move the mini cubes by tapping them, but I can't get my head around how to select specific nodes (childnodes of the big cube).
任何人都可以帮助我或发布一个指向SceneKit教程的链接对于傻瓜?我一直在寻找几天,但还没有找到我想要的东西。
Can anybody help me or post a link to SceneKit tutorials for dummies? I've been looking for days now, and haven't found what I'm looking for.
干杯
推荐答案
您可以点击测试场景视图(例如从点击手势识别器的位置),这将为您提供命中测试结果的列表。从每个结果中,您可以获得节点(和其他信息):
You can hit test the scene view (for example from the location of a tap gesture recognizer), which will give you a list of hit test results. From each result you can get the node (and other information):
let location: CGPoint = // for example from a tap gesture recognizer
let hits = self.sceneView.hitTest(location, options: nil)
if let tappedNode = hits?.first?.node {
// do something with the tapped node ...
}
这篇关于在SceneKit(Swift)中点击/选择节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!