【问题标题】:SKAction moves sprite in front of othersSKAction 将精灵移动到其他人面前
【发布时间】:2015-02-23 21:44:18
【问题描述】:

我正在尝试为我的一个精灵设置动画。问题是在运行 SKAction 时,这个精灵出现在所有其他精灵的前面。它不会像我预期的那样工作。

当用户按下按钮移动时,我正在运行这个函数来为我的精灵设置动画。

 -(void)RightTurn
 {
     [sprite1 removeAllActions];

         turn = [SKAction repeatAction:[SKAction animateWithTextures:@[texture1, texture2, texture3] timePerFrame:0.05] count:1];
     [sprite1 runAction:turn];

}

加载场景时声明所有纹理。当我释放一个按钮时,我正在删除所有动作,此时精灵回到它所属的位置。所以我很确定这是 SKAaction 问题。我在其他地方找不到类似的问题,所以有人知道吗?

【问题讨论】:

  • 您是否偶然在 Xcode 中使用游戏模板创建了项目?
  • @MobileBen 我不记得了。也许是吧?为什么?
  • 你有GameScene和GameViewController吗?而且您没有手动创建它们?
  • @MobileBen 确实如此。那么有什么问题呢?
  • 看看 GameViewController.m 看看这条线是否存在skView.ignoresSiblingOrder = YES;。如果是这样,请尝试将其设置为 NO 并查看是否有效。

标签: ios sprite-kit skspritenode z-order skaction


【解决方案1】:

您需要设置精灵的 z 位置。将 spriteObject.zPosition 设置为小于其他精灵的 z 位置。这将解决您的问题。

【讨论】:

    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多