2015-07-10 48 views
0

我在Xcode中使用swift創建Iphone遊戲,並且有一個球我希望它保持不斷旋轉,我想我需要使用更新方法,但我怎麼能做到這一點,如果有使用更新法出另一種方式請讓我知道如何使屏幕上的對象旋轉,在迅速

+0

您使用的是SpriteKit嗎? –

+0

@robmayoff是的。 –

回答

0

你可以使用一個SKAction(看看的documentation;你會看到SKActions具有多種用途)。對於旋轉,你可以這樣做:

// The angle is measured in radians and the duration is measured in seconds. 
let rotateAction = SKAction.rotateByAngle(1, duration: 1) 

做出的動作來看永遠可以使用另SKAction

let repeatAction = SKAction.repeatActionForever(rotateAction) 

最後,你需要讓你的節點(球)運行的操作:

ball.runAction(repeatAction) 

查看SKNode documentation的其他方法,您可以使用其他方法運行SKAction

此外,我假設你是Sprite Kit的新手,所以我建議你看看The Sprite Kit Programming Guide