Unarchiving and initializing SKScene From.sks

In a 608 WWDC 2014 session, Apple demonstrates how you can customize a scene through a .sks file. Before that, I would create SKScene (in my OS X SpriteKit application) using the following code in the AppDelegate.m class:

 SKScene *scene = [SomeSKSceneClass sceneWithSize:CGSizeMake(width, height)]; //this calls the initWithSize method in my SKScene class 

In the initWithSize I would set the class. However, now that the scene is set using the unarchiveFromFile method in AppDelegate.m , where should I call my scene initialization method? Should this be done in the didMoveToView method?

Here's what it looks like now. This code is from the AppDelegate.m class:

 GameScene *scene = [GameScene unarchiveFromFile:@"GameScene"]; 

Hope this is clear if I can't add more details. I really need some clarification. Please put me in the right direction. Thanks in advance!

+5
source share

Source: https://habr.com/ru/post/1211482/


All Articles