问题
I'm starting to build my first game using spritekit. Right now I have only one View Controller which presents the start screen scene:
override func viewDidLoad() {
super.viewDidLoad()
let scene = StartScreenScene()
// Configure the view.
let skView = self.view as SKView
skView.showsFPS = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
After the start screen is loaded it presents the next scene and so on. While this is working for me I'm not sure if it's correct or if it may hurt performance. Should I have a View Controller for each scene? How many View Controllers should I have?
回答1:
Short answer: 1 is fine!
Long answer: It depends on what you want to have in your application! I have a SpriteKit game that has 3 non-modal ViewControllers: The title screen, the level selection, and the main game screen. However, all of my gameplay is contained within one. SKView
can very easily manage unloading/loading scenes with presentScene
and presentScene:transition:
.
来源:https://stackoverflow.com/questions/25577743/how-many-view-controllers-should-i-have-in-my-game