Goal: A red rectangle (of class Brick) should appear in a blue background with node count and fps.
Reality: Gray background and node count and fps (e.g. no red rectangle or blue background)
I have the following code:
GameViewController
import SpriteKit
class GameViewController: UIViewController {
override func loadView() {
self.view = SKView(frame: UIScreen.mainScreen().bounds)
}
override func viewDidLoad() {
super.viewDidLoad()
let scene: GameScene = GameScene()
let viewAsSKView = self.view as! SKView
viewAsSKView.showsFPS = true
viewAsSKView.showsNodeCount = true
viewAsSKView.backgroundColor = UIColor.blueColor()
viewAsSKView.presentScene(scene)
}
}
My best guess it that something's wrong with GameViewController, but I'm not sure what. viewDidLoad() must've been called because I get the fps and node count.
GameScene
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
let myBrick = Brick()
myBrick.position = CGPointMake(100, 100)
self.addChild(myBrick)
}
}
By the lack of complexity, I assume nothing is wrong with GameScene.
AppDelegate
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.orangeColor()
self.window!.rootViewController = GameViewController()
self.window!.makeKeyAndVisible()
return true
}
I know that nothing is wrong with my AppDelegate, because if I changed self.window!.rootViewController to UIViewController, I get my orange screen.