Roman Safin Roman Safin - 2 years ago 176
iOS Question

How to build a multilevel game in SceneKit

I'm an iOS developer and have plenty of business apps done. Some time ago I decided to try and write a 3D game for iPad using SceneKit. I understand how to create SCNView and SCNScene instances and how to load my scene from .dae files, but I'm having trouble understanding scene transition logic.

Could someone explain the logic of transitioning between different game levels in SceneKit. I haven't found any transition methods between SCNView and SCNScenes

For example: I have 2 levels of game (SCNScene instances). After the player finishes playing the first level, I show the score view (SpriteKit overlay probably), and after that I want to load player character adding stats (for example). After all that, the second level of the game should show.

What architectural concept works in SceneKit for loading different levels in succession?
Should I transition between SCNView or do I need to use a basic transition between view controllers (i.e., 2 levels packed in different View Controllers with a SCNView in each)?.

And if I have the scenes: "Main Menu", "In-App Purchase Store", "Select Player Hero", etc, what concept should I use to transition between the game scene and these?.

So far all examples I have seen are based around a 1-scene game ("Banana", "Fox Apple" WWDS examples).

I would appreciate any help/info/links that will help me to understand. Thank you.

Answer Source

On iOS 9 and OS X 10.11 there's a new method on SCNSceneRenderer that does what you want: -presentScene:withTransition:incomingPointOfView:completionHandler:.

On previous versions you can indeed build a transition in SpriteKit and display it in the overlay SpriteKit scene while reconfiguring the SceneKit scene. Or you could use UIKit and use animations to swap between two views.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download