Xcode 9.1 (and 9.2) - Handled sprites are not executed. Actions added to Scene Editor

I came across some unexpected behavior when using the SpriteKit scene editor and am wondering if anyone else has a problem.

I created a sprite in the scene and added Actions to move it using the scene editor. Actions play fine when I click the animation button in the editor. I add a link to this scene to the main scene using the SKReferenceNode object in the scene editor, and the sprite appears on the main scene, as expected in the editor. However, when I create and run the application, a sprite appears, but no action is taken. I tried this on the beta version of Xcode 9.2 and got the same result. If I load a sprite scene directly from the main view controller, all actions are performed as expected, so it seems that the problem is with the specified nodes. I also found that if I redefine didMove (on :) in the main scene the swift class and put a breakpoint in it, then just click "continue" when it gets to the breakpoint, all actions will play on the sprite sprites, as expected . If I disable the breakpoint, no actions will be performed on the reference sprites. (So, my workaround is to just use a breakpoint and click the Continue button).

Another interesting point. I opened a sample project created with an older version of Xcode, and sprites sprites performed their actions in order. I copied this old SKS file to my project, and Actions worked fine ... until I edited the SKS file (another action was added), then they no longer worked.

+7
source share
4 answers

I had the same problem and it drove me crazy. I tried to install .isPaused on stage and on separate sprites. Nothing worked except for the method of inserting a breakpoint. This is not a solution.

I found that if I set the pause to true and false (this is the value I wanted), then this worked for all sprites.

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

This is a rather annoying bug in the scene editor that needs to be fixed.

+7
source

I asked a similar question just the other day: Xcode 9: SKEditorReference does not allow animation?

The only way I was able to get this to work was to put isPaused on the exact sprite node that I was trying to animate (in the ref node) I created the whole scene / sks file and dragged it to my main scene).

I tried isPaused = false at the top level, the main scene was madeMove to view without effect, and then added isPaused = false to the main node link, without effect. It only worked when I added isPaused = false to the actual sprite that I was trying to revive. I removed isPaused = false from the main and ref nodes, and as long as it was still on the sprite node (inside the ref node), I tried to revive: success.

The bottom line seems that isPaused = false is required for any sprites in the node link.

+1
source

Hi, I had the same problem. Below is my solution:

 override func didMove(to view: SKView) { sleep(1) } 

However, this is not a good way. I hope I can help you temporarily. If you solved this problem or found a better solution, please answer me, thanks.

0
source

Unfortunately, this problem persists in Xcode10. If you use custom classes, either directly or as the parent node, the easiest way to fix this is to add self.isPaused = false to the init?(coder aDecoder: NSCoder) your custom class.

0
source

Source: https://habr.com/ru/post/1273821/


All Articles