ios - How to reference the current Viewcontroller from a Sprite Kit Scene -


I have difficulty finding the answer to this question, I think it is not difficult.

How can I define methods and properties defined on a visual controller from SKScene?

And build on it: How can you refer to the ViewController reference from SKScene that was loaded inside of another SKScene?

Avoid SKScene context from UIViewController Should, because it breaks MVC pattern.

Optionally you use NSNotificationCenter for UIViewController about high scores:

in ViewController :

  - (zero) awakeFromNib {[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (reportScore) Name: @ "ReportScore" object: zero]; } - (Zero) Report: Type: (NSNotification *) Information {NSDictionary * userInfo = [Information user information]; NSNumber * score = (NSNumber *) [userInfo objectForKey: @ "scores"]; // Do your stuff with GameCenter ....} - (Zero) dealloc {// If you do not remove yourself as a supervisor, try the notification object // Disconnected object to // object object And will continue. . [[NSNotificationCenter defaultCenter] Delete the Observer: Self]; }   

in SKScene :

  - (zero) game more often {NSDictionary * userInfo = [Object with NSDictionary dictionary: [NSNumber numberAd : To self Score: @ "score"]; [[NSNotificationCenter defaultCenter] postNotificationName: @ "ReportScore" Item: Self User Info: userInfo]; }    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -