/* |
Copyright (C) 2014 Apple Inc. All Rights Reserved. |
See LICENSE.txt for this sample’s licensing information |
|
Abstract: |
|
Application delegate for the OS X version of Adventure. |
|
*/ |
|
|
import SpriteKit |
|
@NSApplicationMain |
class AppDelegate: NSObject, NSApplicationDelegate { |
// MARK: Properties |
|
var scene: AdventureScene! |
|
@IBOutlet weak var coverView: NSView! |
|
@IBOutlet weak var view: SKView! |
|
@IBOutlet weak var loadingProgressIndicator: NSProgressIndicator! |
|
@IBOutlet weak var gameLogo: NSImageView! |
|
@IBOutlet weak var archerButton: NSButton! |
|
@IBOutlet weak var warriorButton: NSButton! |
|
// MARK: Application Life Cycle |
|
func applicationDidFinishLaunching(aNotification: NSNotification) { |
loadingProgressIndicator.startAnimation(self) |
|
AdventureScene.loadSceneAssetsWithCompletionHandler { |
self.scene = AdventureScene(size: CGSize(width: 1024, height: 768)) |
self.scene.scaleMode = .AspectFit |
|
self.scene.finishedMovingToView = { |
// Remove the cover view so the user can see the scene. |
self.coverView.removeFromSuperview() |
|
// Stop the loading indicator once the scene is completely loaded. |
self.loadingProgressIndicator.stopAnimation(self) |
self.loadingProgressIndicator.hidden = true |
|
// Show the character selection buttons so the user can start playing. |
self.archerButton.alphaValue = 1.0 |
self.warriorButton.alphaValue = 1.0 |
} |
|
self.view.presentScene(self.scene) |
} |
|
#if DEBUG |
view.showsFPS = true |
view.showsNodeCount = true |
view.showsDrawCount = true |
#endif |
} |
|
// MARK: IBActions |
|
@IBAction func chooseArcher(_: AnyObject) { |
scene.startLevel(.Archer) |
gameLogo.hidden = true |
|
archerButton.alphaValue = 0.0 |
warriorButton.alphaValue = 0.0 |
} |
|
@IBAction func chooseWarrior(_: AnyObject) { |
scene.startLevel(.Warrior) |
gameLogo.hidden = true |
|
archerButton.alphaValue = 0.0 |
warriorButton.alphaValue = 0.0 |
} |
} |