菜鸟教程小白 发表于 2022-12-13 08:06:59

ios - Xcode - SKSceneKit 关卡编辑器 - 如何连接到 .h 中的变量


                                            <p><p>在 Xcode 中,如何将关卡编辑器中的项目连接到 .h 文件中的变量?我似乎在任何地方都找不到文档。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您是在谈论 SpriteKit(2D 游戏引擎,带有用于归档为 <code>.sks</code> 文件的 <code>SKScene</code> 对象的 Xcode 编辑器)还是 SceneKit(3D 游戏引擎,带有从 <code>.dae</code> 或 <code>.abc</code> 文件导入的 Assets 的编辑器)?</p>

<p>在任何一种情况下,您都不会像在 Interface Builder 中那样将对象直接连接到代码( Storyboard或 <code>xib</code>/<code>nib</code> 文件)。 (虽然这将是一个很棒的 <a href="http://bugreport.apple.com" rel="noreferrer noopener nofollow">feature request</a> !)相反,您在场景编辑器中为实体设置名称(标识符);然后,在代码中,您可以通过名称查找实体。</p>

<p>在 SpriteKit 中,使用 <a href="https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKNode_Ref/index.html#//apple_ref/occ/instm/SKNode/childNodeWithName%3a" rel="noreferrer noopener nofollow">childNodeWithName:</a> <code>SKScene</code> 对象上的方法来查找命名节点。见 <a href="https://developer.apple.com/library/prerelease/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Nodes/Nodes.html#//apple_ref/doc/uid/TP40013043-CH3-SW17" rel="noreferrer noopener nofollow">Searching the Node Tree</a>用于高级搜索选项(例如递归搜索后代节点)。</p>

<p>在 Scene Kit 中,使用 <a href="https://developer.apple.com/library/prerelease/mac/documentation/SceneKit/Reference/SCNNode_Class/index.html#//apple_ref/occ/instm/SCNNode/childNodeWithName%3arecursively%3a" rel="noreferrer noopener nofollow"></a> <code>SCNScene</code> 对象的 <a href="https://developer.apple.com/library/prerelease/mac/documentation/SceneKit/Reference/SCNScene_Class/index.html#//apple_ref/occ/instp/SCNScene/rootNode" rel="noreferrer noopener nofollow"><code>rootNode</code></a> 上的方法找到一个命名节点。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Xcode - SKSceneKit 关卡编辑器 - 如何连接到 .h 中的变量,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24269394/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24269394/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Xcode - SKSceneKit 关卡编辑器 - 如何连接到 .h 中的变量