【问题标题】:zRotation is not coordinated with movementz旋转与运动不协调
【发布时间】:2015-12-05 21:09:34
【问题描述】:

我正在尝试使用 SpriteKit 为 iPhone 制作 iPod Classic 的游戏 Vortex(https://www.youtube.com/watch?v=LPN-vdeEsiE) 版本。我有这段代码,以便平台围绕中心运行:

    let dx = base!.position.x - self.frame.width/2
    let dy = base!.position.y - self.frame.height/2

    let rad = atan2(dy, dx)

    path = UIBezierPath(arcCenter: circle!.position, radius: (circle?.position.y)! - 191.39840698242188, startAngle: rad, endAngle: rad + CGFloat(M_PI * 4), clockwise: true)
    let follow = SKAction.followPath(path.CGPath, asOffset: false, orientToPath: true, speed: 200)
    base?.runAction(SKAction.repeatActionForever(follow))

但问题是节点的 zPosition 指向路径而不是中心,如您所见here

它应该以这个方向旋转:

请有人帮我解决这个问题,我将不胜感激。谢谢

【问题讨论】:

    标签: ios sprite-kit uibezierpath


    【解决方案1】:

    在我看来,您的飞船旋转偏离了 90 度。似乎最简单的解决方案就是将源图像旋转 90 度。这样一来,您根本不需要更改代码。

    【讨论】:

    • 谢谢!我不敢相信我以前没有看到它
    猜你喜欢
    • 2014-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    • 2019-04-23
    • 2021-08-27
    相关资源
    最近更新 更多