2

I'd like to add an init() to my class that inherits from SKScene instead of doing all my setup in the didMoveToView() method. The problem happens when I try to create a new instance of the scene nextScene = Level1(fileNamed: "Level1"). I get an error saying I need to pass in an NSCoder to my Level1 class instead of using fileNamed: and suggests doing Level1(aCoder: NSCoder). I don't want to use an NSCoder, but rather the fileNamed: to create a new level. Has anyone else experienced this?

claassenApps
  • 1,137
  • 7
  • 14
  • 2
    I'm curious as to why you are wanting to create a custom `init()` as opposed to using `didMoveToView()`. It is not something I've heard of someone doing before. – Charles Caldwell Jun 15 '16 at 13:48
  • My thought process was that I could get some of the loading of the level done in the init() method when the scene is instantiated and the rest of it done in the didMoveToView() when the level is being transitioned to. I thought this might help the level feel like it was loading faster - sometimes the transition seems to lag/catch up during the transition to the new scene. I wasn't sure if it would actually help, but it was something I wanted to try. It must not be a common thing to do then? – claassenApps Jun 15 '16 at 14:11
  • I think that a split method is not faster if you do not use something like asynchronous queue. May be build a custom view with a load bar for the next level is better. – Simone Pistecchia Jun 15 '16 at 16:26
  • Thank you both for your input! – claassenApps Jun 15 '16 at 18:03

0 Answers0