Xcode 9:SKEditorReference不允许动画吗? [英] Xcode 9: SKEditorReference doesn't allow animations?

查看:96
本文介绍了Xcode 9:SKEditorReference不允许动画吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法获得通过引用添加的sprite节点(将一个sks文件拖放到Xcode 9中的另一个sks文件中)进行动画处理。这似乎是可以允许的,因为您实际上可以做这样的事情,但是我不确定子节点为什么不进行动画处理。

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.

示例
1。从标准的spritekit模板
开始2.添加HUD.sks文件,并在某处添加一个彩色sprite,将其命名为 hudSpriteNode
3.将HUD.sks文件拖到GameScene.sks场景中-中心它在零处
4.找到hudSpriteNode(按名称)
5.使用.position移动(有效!)
6.使用动画移动(失败!)

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

HUD.sks

GameScene.sks

GameScene.sks

将此代码添加到GameScene.swift

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.

推荐答案

请参阅@Marcel的链接。他向我指出的帖子大部分是通过提供一些其他更新/验证来达到目的的。但是,使它起作用的唯一方法是将isPaused放在我要进行动画处理的确切Sprite节点上(在我的ref节点内)。

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).

我在顶层尝试了isPaused = false,没有将主场景移动到视图中,但是没有任何效果,然后将isPaused = false添加到了主引用节点,没有效果。仅当我添加isPaused = false实际的精灵(在添加的ref节点内)时,它才起作用。我从主&中删除了isPaused = false。 ref节点,并且只要isPaused = false仍在所讨论的sprite节点上(我试图制作动画的ref节点中的那个):

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.

底部这行似乎是在引用节点中包含的所有精灵上都需要isPaused = false。

Bottom line seems to be that isPaused=false is required on any sprites contained within reference nodes.

这篇关于Xcode 9:SKEditorReference不允许动画吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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