[Swift 2] Day 6 - Game Challenge #1 Solution + Demos


#41

This is how far the game is now :smile:

Please note that is still buggy and it runs kinda bad on the appetize.io


#42

@PaulSolt

I’ve run into a huge annoying problem :smile:

When a player dies and decides to go back to the main screen I navigate away from the ViewController that parents the GameScene. When you start a new game you go back to the GameViewController, which however creates a new GameScene on top of the old one :frowning:
I tried different ways of doing it…but can’t figure it out.
I tried saving a reference to the existing Scene and just load it and reset it, but I get a gray scene ( empty ) for some reason…

I tried removign all children from the old one and setting it to nil, before loading the new one, but it still didn’t work…


#43

you need to prevent the GameScene from being recreated along with the ViewController.

Whoever owns the ViewController/GameScene needs to establish ownership of those view controllers so they aren’t thrown away when you navigate.


#44

@PaulSolt I am not sure I completely understand that…you need to have the same ownership for all view controllers on the SB ?


#45

What ViewControllers are in your project?

Where are they created?

Ideally you don’t want to recreate a viewController in your viewDidLoad or didMoveToView methods. One of your code files needs to keep track of what has been created and provide an alternate way of showing the content.

Day 11’s lesson has some new videos on animating between the different pause and game screens. Look at how I stored the screens in the GameViewController.swift file.


#46

Will do, thanks.
I’ll let you know.