I am building a replica of "Space Invaders" in Swift. The error I am getting:
Use of Undeclared Type 'Set'
The following is a sample of my code:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as UITouch
let touchLocation = touch.locationInNode(self)
let touchedNode = self.nodeAtPoint(touchLocation)
if(touchedNode.name == "startgame"){
let gameOverScene = GameScene(size: size)
gameOverScene.scaleMode = scaleMode
let transitionType = SKTransition.flipHorizontalWithDuration(1.0)
view?.presentScene(gameOverScene,transition: transitionType)
}
}
and:
override func touchesBegan(touches: Set <NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as Set<UITouch>) {
let location = touch.locationInNode(self)
let sprite = SKSpriteNode(imageNamed:"Spaceship")
sprite.xScale = 0.5
sprite.yScale = 0.5
sprite.position = location
let action = SKAction.rotateByAngle(CGFloat(M_PI), duration:1)
sprite.runAction(SKAction.repeatActionForever(action))
self.addChild(sprite)
}
}
In both cases the error occurs at: (touches: Set<NSObject>, withEvent event: UIEvent)
Can someone please suggest a possible solution?