Xcode 9.1(和 9.2) - 引用的精灵不执行场景编辑器中添加的动作 [英] Xcode 9.1 (and 9.2) - Referenced sprites are not executing Actions added in Scene Editor

查看:14
本文介绍了Xcode 9.1(和 9.2) - 引用的精灵不执行场景编辑器中添加的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 SpriteKit 场景编辑器时遇到了一些意外行为,想知道是否其他人也遇到了同样的问题.

I have come across some unexpected behaviour when using the SpriteKit Scene Editor, and wonder if anyone else is having the same issue.

我在场景中创建了一个精灵,并添加了动作以使用场景编辑器移动它.当我单击编辑器上的动画按钮时,动作播放正常.我在场景编辑器中使用 SKReferenceNode 对象将此场景的引用添加到主场景中,并且精灵按预期在编辑器中出现在主场景中.然而,当我构建并运行应用程序时,精灵出现但没有运行任何动作.我已经在 Xcode 9.2 beta 上尝试过这个并得到相同的结果.如果我直接从主视图控制器加载精灵场景,所有动作都按预期执行,所以这似乎是引用节点的问题.我还发现,如果我在主场景 swift 类中覆盖 didMove(to:) 并在其中放置一个断点,然后在它到达断点时点击继续,所有动作都会按预期在引用的精灵上播放.如果我禁用断点,则不会在引用的精灵上播放任何动作.(所以我的解决方法是简单地使用断点,然后点击继续按钮)

I created a sprite in a scene and added Actions to move it around using the Scene Editor. The Actions play fine when I click the animate button on the editor. I add a reference to this scene to the main scene using the SKReferenceNode object in the Scene Editor, and the sprite appears in the main scene as expected in the Editor. When I build and run the app however, the sprite appears but no Actions run. I have tried this on the Xcode 9.2 beta and get the same result. If I load the sprite scene directly from the main view controller, all the Actions execute as expected, so it seems to be an issue with referenced nodes. I also found that if I override didMove(to:) in the main scene swift class, and put a breakpoint in it, then just hit continue when it hit the breakpoint, all Actions play on referenced sprites as expected. If I disable the breakpoint, no Actions play on referenced sprites. (So my workaround is to simply use the breakpoint, and hit the continue button)

另一个有趣的观察.我打开了一个用旧版本的 Xcode 创建的示例项目,并且引用的精灵很好地执行了它们的动作.我将这个较旧的 SKS 文件复制到我的项目中,并且 Actions 运行良好......直到我编辑了 SKS 文件(添加了另一个 Action),然后它们就再也没有工作了.

Another interesting observation. I opened a sample project created with an older version of Xcode, and referenced sprites executed their Actions fine. I copied this older SKS file into my project and Actions worked fine...until I edited the SKS file (added another Action), then they never worked again.

推荐答案

我遇到了同样的问题,这让我发疯了.我尝试在场景和单个精灵上设置 .isPaused.除了插入断点方法外,没有任何效果.这不是解决方案.

I had this same problem and it was driving me crazy. I tried setting the .isPaused on the scene and on the individual sprites. Nothing worked except the insert breakpoint method. That is not a solution.

我发现如果我将 is paused 设置为 true 和 false(这是我想要的值),那么它适用于所有精灵.

What I discovered was if I set the is paused to true and false (which is the value I wanted) then it worked for all the sprites.

 override func didMove(to view: SKView) {
    self.isPaused = true
    self.isPaused = false
}

这是场景编辑器中一个非常烦人的错误,应该修复.

This is a pretty annoying bug in scene editor that should be fixed.

这篇关于Xcode 9.1(和 9.2) - 引用的精灵不执行场景编辑器中添加的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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