-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameViewController.swift
More file actions
76 lines (56 loc) · 2.12 KB
/
GameViewController.swift
File metadata and controls
76 lines (56 loc) · 2.12 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
//
// GameViewController.swift
// Dodge100
//
// Created by Aayushi Baral on 2017-12-30.
// Copyright © 2017 Leo's Apps. All rights reserved.
//
import UIKit
import GoogleMobileAds
import SpriteKit
import AVFoundation
class GameViewController: UIViewController{
var backingAudio = AVAudioPlayer()
@IBOutlet weak var bannerView: GADBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Background Audio plays throughout the game
let filePath = Bundle.main.path(forResource: "Track1",ofType:"mp3")
let audioNS_URL = NSURL(fileURLWithPath: filePath!)
do{ backingAudio = try AVAudioPlayer(contentsOf: audioNS_URL as URL)
backingAudio.numberOfLoops = -1
backingAudio.play()}
catch{ return print("No Audio Found")}
// Load the SKScene from 'MainMenuScene.swift'
let scene = MainMenuScene(size: CGSize(width: 1536, height: 2048))
// Set the scale mode to scale to fit the window
let skView = self.view as! SKView
scene.scaleMode = .aspectFill
skView.ignoresSiblingOrder = true
skView.presentScene(scene)
// Google Banner Ads
print("Google Mobile Ads SDK version: \(GADRequest.sdkVersion())")
bannerView.adUnitID = "ca-app-pub-8355047573696380/4206252830"
bannerView.rootViewController = self
//bannerView.load(GADRequest())
// TEST: "ca-app-pub-3940256099942544/2934735716"
// REAL: "ca-app-pub-8355047573696380/4206252830"
}
override var shouldAutorotate: Bool {
return true
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown
} else {
return .all
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Release any cached data, images, etc that aren't in use.
}
override var prefersStatusBarHidden: Bool {
return true
}
}