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

查看:205
本文介绍了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 :),并在其中放置一个断点,那么只要在它到达断点时点击继续,所有Actions按照预期在引用的精灵上播放。如果我禁用断点,则没有操作在引用的精灵上播放。
(所以我的解决方法是简单地使用断点,然后按下继续按钮)

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创建的示例项目,并且引用的sprite执行了他们的Action。我将这个旧的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.

我发现如果我将暂停设置为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天全站免登陆