Pause game on orientation change, objective-c / Sprite Kit -


I want to pause my game when device orientation is started. I have this method in my ViewController, which works fine:

  - (zero) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation Duration: (NSTimeInterval) Period {NSLog (@, I started rotating "Stop game should stop ..");  

}

But how to hear from within my SKScene for the device rotation, where the actual game is playing. Hope I have made myself very clear thanks for any help!

NSNotification

you can use. Keeping with your code, add the following line to your ViewController init:

  [[NSNotificationCenter defaultCenter] postNotificationName: @ "RotateNotification" item: auto];  

Then add this line to your SKScene init:

  [[NSNotificationCenter defaultCenter] addObserver: auto selector: @selector (receiveNotification) Name: @ "Rotate Notification "object: zero];  

Also add the method called for SKScene:

  - (zero) receiveNotification: (NSNotification *) Information {NSLog (@ "Receive Notification") ; // do you have to do here ...}  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -