SKPhysicsJointPin引脚位置 [英] SKPhysicsJointPin pin position

查看:97
本文介绍了SKPhysicsJointPin引脚位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更好地理解SKPhysicsJointPin,特别是锚点参数。

I'm trying to understand SKPhysicsJointPin a bit better, specifically the anchor point parameter.

我了解到锚点是节点的父节点中的位置。有关的两个物理机构。我不了解参与机构在哪一点进行定位,以及是否有办法加以控制。

I understand that the anchor point is the position in the parent node of the two physics bodies concerned. What I don't understand at which point in the participating bodies does the pin go through and if there is a way to control that.

为了使自己更清楚,说我正在用手打钟,因此图钉应位于圆圈的中间,但指针应穿过边缘。

To make myself clear, say I'm making a clock with hands so the pin should go in the middle of the circle but for the hands is should go through the edge. So how can you control that.

谢谢。

推荐答案

这些文档非常缺乏。要使用时钟参考,并且既然您显然知道代码,我将为您提供英语细目分类:

Documentation is pretty lacking for these. To use the clock reference, and since you obviously know the code, I'll give you the English breakdown:


  1. 添加2个时钟指针精灵到场景

  2. 将钟表子画面上的两个锚点都设置为(.5,0)

  3. 将两个子画面上的两个锚点都放置在(100,100)

  4. 创建2个物理物体,将它们添加到每个时针

  5. 创建SKPhysicsJointPin,使用锚点(100,100)

  6. 将关节添加到场景中

  1. add 2 clock hand sprites to the scene
  2. set both anchor points on the clock hand sprites to (.5,0)
  3. position both sprites at (100,100)
  4. create 2 physics bodies, add them to each clock hand
  5. create the SKPhysicsJointPin, use anchor point (100,100)
  6. add the joint to the scene

从理论上讲,您现在应该有2个时针,可以通过自己的锚点旋转围绕场景中的点(100,100)。

You should in theory, now have 2 clock hands, able to spin via their own anchor points around the point in the scene at (100,100).

这篇关于SKPhysicsJointPin引脚位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆