菜鸟教程小白 发表于 2022-12-13 14:55:08

ios - 如何在 Sprite 套件中实现齿轮接头?


                                            <p><p>Box2d 中的齿轮接头很棒,但我不知道如何在 Sprite Kit 中实现它。有什么解决方案可以在 Sprite Kit 中实现齿轮接头吗? </p>

<p>谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>以下是可用的 Sprite-Kit 关节:<a href="https://developer.apple.com/reference/spritekit/skphysicsjoint" rel="noreferrer noopener nofollow">https://developer.apple.com/reference/spritekit/skphysicsjoint</a> </p>

<p> <a href="/image/p9szB.png" rel="noreferrer noopener nofollow"><img src="/image/p9szB.png" alt="enter image description here"/></a> </p>

<p>据我了解,与 Box2D 的齿轮关节似乎没有直接关系,它似乎在另一个 body 旋转时使一个 body 旋转。</p>

<p>在这种情况下,您可能需要研究覆盖 didSimulatePhysics 或 didFinishUpdate 方法,以根据另一个对象的旋转手动设置一个对象的旋转:</p>

<p> <a href="https://developer.apple.com/reference/spritekit/skscene/1519965-didsimulatephysics" rel="noreferrer noopener nofollow">https://developer.apple.com/reference/spritekit/skscene/1519965-didsimulatephysics</a> </p>

<p> <a href="https://developer.apple.com/reference/spritekit/skscene/1520269-didfinishupdate" rel="noreferrer noopener nofollow">https://developer.apple.com/reference/spritekit/skscene/1520269-didfinishupdate</a> </p>

<p>可能很简单:</p>

<pre><code>wheel2.zRotation = wheel1.zRotation
</code></pre>

<p>但如果齿轮的齿数不同(因此传动比不同),您就必须进行一些计算。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在 Sprite 套件中实现齿轮接头?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42502669/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42502669/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在 Sprite 套件中实现齿轮接头?