2017-03-16 37 views
1

在這裏,我有一組上SCNSphere作用的動畫稱爲testNode如何檢查是否SCNAction斯威夫特卡倫特3已經完成

//run this during the duration of the two animations below 
earthNode.runAction(SCNAction.rotateBy(x: 0, y: 5, z: 5, duration: 4)) 
//run this action right away 
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: -5, duration: 2)) 
//RUN THIS ACTION AFTER ACTION ABOVE IS COMPLETED 
earthNode.runAction(SCNAction.moveBy(x: 0, y: 0, z: 5, duration: 2)) 

我試圖從在同一時間發生停止最後兩個動畫。我如何檢查第二個動畫是否完成,然後運行列出的最後一個動畫。我也希望能解釋一下檢查一組同時運行的動畫是否完成。

回答

1

你可以做一個序列像SKActions:

/* Actions */ 
let moveUp = SKAction.moveBy(x: 0, y: 100, duration: 1.0) 
let zoom = SKAction.scale(to: 2.0, duration: 0.25) 
let sequence = SKAction.sequence([moveUp, zoom]) 

let node = SKNode() 
node.run(sequence) 

SCNAction.group()SCNAction.sequence()此:

class func group([SCNAction]) 

創建某個動作並行運行一系列操作。

class func sequence([SCNAction]) 

創建一個按順序運行一系列動作的動作(這是你所需要的)。

/* Action with sequence of actions */ 
let move = SCNAction.sequence([moveUp, moveDown, moveLeft, moveRight]) // will be executed one by one 
let rotate = SCNAction.rotateBy(x: 0, y: .pi, z: 0, duration: 2) 

/* Group actions */ 
let group = SCNAction.group([rotate, move]) 

node.runAction(group, completionHandler:nil) 
+0

正是我需要的感謝! – Tim2799

+0

不客氣;] –