0
votes

I have upgraded to Xcode 7-beta and it gives me this error: Cannot invoke 'sequence' with an argument list of type '([AnyObject])'. That error is in this line of code:

sprite.runAction(SKAction.sequence(actionarray as [AnyObject]))

I found that in swift 2 I must remove part of it and it must look like this:

sprite.runAction(SKAction.sequence(actionarray))

But actionarray in NSMutableArray and now it gives me this error: Cannot invoke 'sequence' with an argument list of type '(NSMutableArray)'

This is the content of NSMutableArray:

var actionarray:NSMutableArray = NSMutableArray()
actionarray.addObject(SKAction.moveTo(CGPointMake(self.frame.size.width/2, -sprite.size.height), duration: NSTimeInterval(duration)))
actionarray.addObject(SKAction.removeFromParent())
sprite.runAction(SKAction.sequence(actionarray))

It worked well in Xcode 6. What should I change there?

Thanks

2
What is the contents of your actionarray? Where are you declaring it? Are you sure it contains SKAction objects? - JAL

2 Answers

0
votes

Why do you use NSMutableArray in Swift code in the first place? Try replacing with Swift array like this (compiles in Playground):

import Cocoa
import SpriteKit

let sprite = SKSpriteNode()
var actionarray: [SKAction] = []
actionarray.append(SKAction.moveTo(CGPointZero, duration: NSTimeInterval(1.0)))
actionarray.append(SKAction.removeFromParent())
sprite.runAction(SKAction.sequence(actionarray))
0
votes

Try using this syntax:

SKAction.sequence(actionarray as AnyObject as [SKAction])