-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuVC.swift
More file actions
77 lines (62 loc) · 2.49 KB
/
MainMenuVC.swift
File metadata and controls
77 lines (62 loc) · 2.49 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
//
// GameViewController.swift
// project-mars
//
// Created by Aleksandr Grin on 12/4/16.
// Copyright © 2016 AleksandrGrin. All rights reserved.
//
import UIKit
import SpriteKit
class MainMenuVC: UIViewController {
@IBOutlet weak var SecondaryBackGround: UIView!
@IBOutlet weak var GameTitle: UILabel!
@IBOutlet weak var ContinueButton: UIButton!
@IBOutlet weak var NewGameButton: UIButton!
@IBOutlet weak var OptionsButton: UIButton!
@IBOutlet weak var StatisticsButton: UIButton!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.view.setMainBackgroundwithFit(backgroundName: "Main_BG_final")
SecondaryBackGround.setSecondaryBackground(named: "Secondary_BG_final")
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
if UIDevice.current.orientation.isPortrait {
(self.view.subviews[0] as! UIImageView).frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
}else if UIDevice.current.orientation.isLandscape {
(self.view.subviews[0] as! UIImageView).frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
}
}
override var shouldAutorotate: Bool {
return true
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown
} else {
return .all
}
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "continueGame" {
do {
if try gameState.sharedInstance().isGameInProgress == true {
return true
}else{
return false
}
} catch { print("Error in shouldPreformSegue MainMenuVC") }
}
return true
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "newGameSegue" {
do{ try gameState.sharedInstance().isGameInProgress = false } catch { print("Error in MainMenuVC prepare") }
}
}
//Action for unwinding from the settingsVC
@IBAction func returnFromSettings(segue: UIStoryboardSegue){ }
}