Search code examples
xcode8

Putting a "Game" into my Single View Application in Xcode


I am completely new to Xcode and coding in general, so I've been wanting to create an app where I will have a UI (Start menu, options menu etc) then when the player presses the "start" button, it will bring them to a game.

When I was toying around with Xcode, I realized that if you choose the Game option instead of the single-view application, it will create Spritekit Scene and various tabs needed to create a basic game.

So I was wondering is it possible to add all those tabs needed into my SingleViewApplication or do I have to copy everything from my current game to a new project with the "Game" preset?

Any input would be appreciated!


Solution

  • Theoretically, you can just copy the appropriate files from a "Game" project to a "Single View Application" project, because the Game project template essentially adds a single view controller in the storyboard and put an SKView in the VC. I have never done this before though.

    What you need to copy:

    • The view controller from the storyboard of the Game (You need to connect this VC to the existing VCs in your SingleViewApplication of course.)
    • The class of the VC (remember to set this as the class of the VC if it is not set)
    • The SKScene subclass(es)
    • The sks files
    • all the graphics in the assets catalog

    However, I don't recommend you doing this because UIViews components feels very different from SKNodes. This might make your app's style inconsistent. I suggest doing all the menus and stuff in SpriteKit as well.