I can't seem to get sprite nodes that have been added by reference (drag/drop one sks file into another sks file in Xcode 9) to animate. This seems allowable, as you can physically do such a thing, but I'm unsure why the sub-nodes won't animate.
Example
1. Start with standard spritekit template
2. add a HUD.sks file, and add a color sprite somewhere, name it "hudSpriteNode"
3. drag the HUD.sks file into the GameScene.sks scene - center it at zero
4. find the hudSpriteNode (by name)
5. move it with .position (works!)
6. move it with animation (fails!)
HUD.sks
GameScene.sks
Add this code to GameScene.swift
if let testSpriteNode = childNode(withName: "//hudSpriteNode") as? SKSpriteNode {
print("Found test sprite node")
print("Test node position 1: \(testSpriteNode.position)")
testSpriteNode.position = CGPoint.zero
print("Test node position 2: \(testSpriteNode.position)")
testSpriteNode.run(SKAction.moveBy(x: 200, y: 200, duration: 4))
}
Run... position is moved correctly, but animation fails.
See link by @Marcel in the comments. The post he pointed me to mostly did the trick with some additional updates/validation on my part. The only way I was able to get this to work, though, was to put the isPaused on the exact sprite node I was trying to animate (within my ref node).
I tried isPaused=false at the top level, main scene didMove to view, but to no effect, and then added isPaused=false to the main reference node, to no effect. It worked only when I added isPaused=false the actual sprite (within the ref node I had added) I was trying to animate. I removed isPaused=false from the the main & ref nodes, and as long as isPaused=false was still on the sprite node in question (the one within the ref node I was trying to animate): success.
Bottom line seems to be that isPaused=false is required on any sprites contained within reference nodes.
See @Eric post.
Instead of applying to SKSpriteNode itself, applying to the top level of SpriteKit scene (the main scene) did the trick for me.
spriteKitScene?.isPaused = false
It would seem to depend on the context of use, mine was animating a SpriteKit scene in a SCNPlane, which would then be handled by ARKit 2.
plane.firstMaterial?.diffuse.contents = spriteKitScene
See similar issue on Apple Developer Forums.
Note: Running on Xcode 10 Beta 6.