There are several posts on the internet asking how to correctly combine SpriteKit and Storyboard/Interface builder. In particular nobody is able to move from an SKscene to a desired UIViewController. NONE of the solutions on the net really address this problem! Is it really not possible to do this?? If so, it would be a significant limitation of SpriteKit...
You cannot move directly from an SKScene
to another UIViewController
.
However, the SKScene
is already contained in a UIViewController
.
You can use delegation
to pass a method call from the scene to its controller. The controller can then move to another view controller.
So...
Create a delegate protocol that contains a method something like... - (void)transitionToOtherViewController;
Set the current view controller as the delegate of your scene.
self.scene.delegate = self;
When you want to move to another view controller. In the scene you would have something like...
[self.delegate transitionToOtherViewController];
Then in the view controller you have...
- (void)transitionToOtherViewController
{
MyOtherViewController *controller = [MyOtherViewController new];
[self.navigationController pushViewController:controller animated:YES];
}
Or something like this...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.