var actionArray:NSMutableArray = NSMutableArray()
actionArray.addObject(SKAction.moveTo(finalDestination, duration: NSTimeInterval(moveDuration)))
actionArray.addObject(SKAction.removeFromParent())
torpedo.runAction(SKAction.sequence(actionArray as [AnyObject]))
错误:'NSMutableArray'不能隐式转换为'[AnyObject]';你的意思是使用'as'来明确转换吗?
第二个问题,因为我不能经常发布与早期问题非常相似的内容:
var actionArray:NSMutableArray = NSMutableArray()
actionArray.addObject(SKAction.moveTo(CGPointMake(position, -alien.size.height), duration: NSTimeInterval(duration)))
actionArray.addObject(SKAction.runBlock({
var transition:SKTransition = SKTransition.flipHorizontalWithDuration(0.5)
var gameOverScene:SKScene = GameOverScene(size: self.size, won:false)
self.view?.presentScene(gameOverScene, transition: transition)
}))
actionArray.addObject(SKAction.removeFromParent())
alien.runAction(SKAction.sequence(actionArray as [SKAction]))
我不知道为什么我会收到此信息,但自从我切换到Xcode 7后,所有这些错误都会弹出。任何帮助都表示赞赏!谢谢!
答案 0 :(得分:2)
抱歉应该是...... 1.
var actionArray:[SKAction] = [SKAction]()
actionArray.append(SKAction.moveTo(....
actionArray.append(SKAction.removeFromParent())
torpedo.runAction(SKAction.sequence(actionArray))
var actionArray:[SKAction] = [SKAction]()
ditto the rest