Passing Data from a View Controller to a Cocos2D Scene
cocos2d-iphone, ios, objective-c, uiviewcontroller
Solution
I think you can do it by assigning value to a class variable....
Code snippet will look like this...
[[CCDirector sharedDirector] replaceScene:[GameScene scene:data]];
in your `GameScene.m`
@implementation GameScene
@synthesize ...
+ (CCScene *) scene:(Datatype *)data
{
self.dataReceived = data;
CCScene * .....
.......
}
Something like this may help.. I did this in cocos2d-x and it works fine.. M sorry for syntax as I don't have X-code.... :)
Problem
In my game, I use Cocos2D for physics in the gameplay and UIKit for the menu screen and the rest of the game. Now, I have to pass the data from a UIViewController to a Cocos2D scene. Is there a way to do this?