数组变化 Swift 2

Changes in array Swift 2

我已经更新到 swift 2,但迁移工具无法更新我的阵列。这是我收到错误的地方:

        actionArray.addObject(SKAction.moveTo(CGPointMake(position, -alien.size.height), duration: NSTimeInterval(duration)))

        actionArray.addObject(SKAction.removeFromParent())
        actionArray2.addObject(SKAction.moveTo(CGPointMake(position, -alienAzul.size.height), duration: NSTimeInterval(duration)))

        actionArray2.addObject(SKAction.removeFromParent())

它是这样写的:

Value of type '[SKAction]' has no member 'addObject'

你必须使用append(newElement: Element)

Swift 的最佳做法是按如下方式使用数组:

将数组变量定义为

var actionArray: [SKAction]!

实例化它:

actionArray = [SKAction]()

向其中添加对象:

actionArray.append(sKAction)