【问题标题】:How to calculate the speed of falling ball in sprite kit如何计算精灵套件中落球的速度
【发布时间】:2013-10-03 15:02:30
【问题描述】:

我正在尝试获得弹跳球效果,但我并没有真正遇到问题。
我想弄清楚的是如何计算球的速度。

我知道它在 Box2d 中是这样完成的

b2Vec2 velocity = b->GetLinearVelocity();
float32 speed = velocity.Length();


这些行是如何转换为 sprite kit 的? 谢谢

编辑: 如果这对速度正确,我正在尝试任何想法

static inline CGFloat CGPointLength(const CGVector a) {
    return sqrtf(a.dx * a.dx + a.dy * a.dy);
}

  CGVector velocity=circle.physicsBody.velocity;
  float speed=CGPointLength(velocity);

【问题讨论】:

    标签: ios objective-c sprite-kit


    【解决方案1】:

    SKNodephysicsBody 有一个用于 velocityCGVector 属性,可用于计算速度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多