-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOverScene.swift
More file actions
85 lines (63 loc) · 2.39 KB
/
GameOverScene.swift
File metadata and controls
85 lines (63 loc) · 2.39 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// GameOverScene.swift
// SpriteKit1
//
// Created by Fernando on 5/4/15.
// Copyright (c) 2015 Fernando. All rights reserved.
//
import Foundation
import SpriteKit
let GameOverLabelCategoryName = "gameOver"
let GameOverTap = "tap"
class GameOverScene: SKScene {
var gameWon : Bool = false {
// 1.
didSet {
let gameOverLabel = childNodeWithName(GameOverLabelCategoryName) as! SKLabelNode
gameOverLabel.text = gameWon ? "You Won" : "Game Over"
let gameOvertapLabel = childNodeWithName(GameOverTap) as! SKLabelNode
gameOvertapLabel.text = gameWon ? "Replay?" : "Try Again?"
}
}
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
let scene:GameScene = GameScene(size: self.size)
let transation = SKTransition.revealWithDirection(SKTransitionDirection.Right, duration: 1.5)
scene.scaleMode = SKSceneScaleMode.AspectFill
self.view!.presentScene(scene, transition: transation)
}
// override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
// if let view = view {
// 2.
// let gameScene = GameScene.unarchiveFromFile("GameScene") as! GameScene
// view.presentScene(gameScene)
//}
//}
}
//init(size: CGSize, won:Bool) {
// super.init(size: size)
// 1
//backgroundColor = SKColor.whiteColor()
// 2
//var message = won ? "You Won!" : "You Lose :["
// 3
//let label = SKLabelNode(fontNamed: "Chalkduster")
//label.text = message
//label.fontSize = 40
//label.fontColor = SKColor.blackColor()
//label.position = CGPoint(x: size.width/2, y: size.height/2)
//addChild(label)
// 4
//runAction(SKAction.sequence([
// SKAction.waitForDuration(3.0),
//SKAction.runBlock() {
// 5
// let reveal = SKTransition.flipHorizontalWithDuration(0.5)
//let scene = GameScene(size: size)
//self.view?.presentScene(scene, transition:reveal)
//}
//]))
//}
// 6
//required init(coder aDecoder: NSCoder) {
// fatalError("init(coder:) has not been implemented")
//}