如何在Swift中进行排序?

时间:2023-01-22 22:44:31

I'm trying to make a simple sequence of two actions but Xcode is saying that I have an extra argument in call. I tried to translate Apples Obj-C example into Swift and it's not going very well. What am I doing wrong?

我试着做一个简单的两个动作的序列但是Xcode说我有一个额外的参数调用。我试着把苹果object - c的例子翻译成Swift,结果不太好。我做错了什么?

func dead() {
    let animateAction = SKAction.animateWithTextures(self.catArray, timePerFrame: 0.09)
    let ending = SKAction.runBlock(self.gameOver)
    let sequence = SKAction.sequence(actions: animateAction, ending)
    self.cat.runAction(sequence)
} 

1 个解决方案

#1


2  

The sequence method of SKAction requires an Array of AnyObject. To fix this, you will need to call the method with the two actions you declared earlier in an array like this:

SKAction的序列方法需要一个AnyObject数组。要解决这个问题,您需要调用前面在数组中声明的两个动作的方法:

let sequence = SKAction.sequence([animateAction, ending])
self.cat.runAction(sequence)

#1


2  

The sequence method of SKAction requires an Array of AnyObject. To fix this, you will need to call the method with the two actions you declared earlier in an array like this:

SKAction的序列方法需要一个AnyObject数组。要解决这个问题,您需要调用前面在数组中声明的两个动作的方法:

let sequence = SKAction.sequence([animateAction, ending])
self.cat.runAction(sequence)