Call Storyboard Scene from a Cocos2d CCMenu

92 views Asked by At

I have integrated cocos2d with storyboard. In the cocos2d view I have a CCMenu with some buttons. I want that when I click a button, open a scene from the storyboard. Is this possible? I want to use buttons from cocos2d.

Thanks.

1

There are 1 answers

0
Corbin87 On

When viewing the storyboard, assign the particular scene you want to launch a storyboard ID from the identity inspector in Interface Builder. Then, make the method that is called by the Cocos2d button call this method:

UIViewController *yourViewController = [[CCDirector sharedDirector].navigationController.storyboard instantiateViewControllerWithIdentifier:@"This is the storyboard ID you made from Interface Builder"];
[[CCDirector sharedDirector].navigationController pushViewController: yourViewController animated:YES];

That code will tell the navigation controller to create and push the storyboard scene with that matching ID.