Transferring data from the view controller to the Cocos2D scene

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 need to transfer data from the UIViewController to the Cocos2D scene. Is there any way to do this?

+4
source share
1 answer

I think you can do this by assigning a value to a class variable ....

The code snippet will look like this:

[[CCDirector sharedDirector] replaceScene:[GameScene scene:data]]; 

at GameScene.m

 @implementation GameScene @synthesize ... + (CCScene *) scene:(Datatype *)data { self.dataReceived = data; CCScene * ..... ....... } 

Something like this might help .. I did it in cocos2d-x and it works fine. Sorry for the syntax as I don't have X code .... :)

+4
source

Source: https://habr.com/ru/post/1411062/


All Articles