SpaceMonkey

###项目
Sprite Kit for Kids with Swift

###编译错误
编译环境:
Xcode Version 6.2 (6C131e)
OS X 10.9.5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
override func viewWillLayoutSubviews() {
super.viewDidLoad()

let skView = self.view as! SKView
if skView.scene == nil {

let scene = GameScene(size:skView.frame.size)
skView.showsFPS = true
skView.showsNodeCount = true
skView.showsPhysics = true
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFill
skView.presentScene(scene)

playBackgroundMusic("BackgroundMusic.mp3")

}

错误信息

Expected type after ‘as’

解决方法
as!===>as

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
// 1
if (!gameOver) {
if player.physicsBody?.dynamic == false {
player.physicsBody?.dynamic = true
touchToBeginLabel.hidden = true
backgroundColor = SKColor.blackColor()

runAction(SKAction.repeatActionForever(
SKAction.sequence([
SKAction.runBlock(spawnEnemy),
SKAction.waitForDuration(1.0)])))
}
// 2
jumpPlayer()

}
// 3
else if (gameOver) {
let newScene = GameScene(size: size)
newScene.scaleMode = scaleMode
let reveal = SKTransition.flipHorizontalWithDuration(0.5)
view?.presentScene(newScene, transition: reveal)
}
}

错误信息

Use of undeclared type ‘Set’

解决方法
Set<NSObject>===>NSObject