我正在制作一个游戏,我有一个在 2 个纹理之间来回切换的节点。我想知道如何在每个纹理切换回前一个纹理之前为每个纹理添加 0.5 秒的持续时间。现在,当我运行游戏时,纹理会立即切换,所以我想延迟 0.5 秒。
我当前的代码:
func move(){
let recursive = SKAction.sequence([
SKAction.setTexture(SKTexture(imageNamed: "D2")),
SKAction.setTexture(SKTexture(imageNamed: "DWalkRight")),
SKAction.moveByX(frame.size.width/2.8, y: 0, duration: NSTimeInterval(randomNumber())),
SKAction.setTexture(SKTexture(imageNamed: "D1")),
SKAction.setTexture(SKTexture(imageNamed: "DWalkLeft")),
SKAction.moveByX(-frame.size.width/2.8, y: 0, duration: NSTimeInterval(randomNumber())),
SKAction.runBlock({self.move()})])
Drake1.runAction(recursive, withKey: "move")
}