Domanda

Let me give an example to illustrate:

e.g. in CocosBuilder, I have created a Scene.ccbi and its custom class Scene class

Inside Scene header, I have defined a method:

-(void) doSomething;

In AppDelegate/ViewController, I call CCBReader to create the CCScene:

CCScene* myScene = [CCBReader sceneWithNodeGraphFromFile:@"Scene.ccbi"];

i.e. Scene.m has its instance now.

In this point, how can AppDelegate/ViewController access the Scene 's instance method? for example, inside ViewController:

Scene *ccbinstrance; // this is the part I don't know to link Scene*
[cbbinstance doSomething];

Thank you!

È stato utile?

Soluzione

Seems no one has a good answer for this. I have a dirty way to resolve this problem. I create a static singleton object and store this reference of Scene. And then it can be called by another viewController using that singleton object.

It's kind of dirty but work for me at the moment...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top