I have a little app up that has both CCLayer view and UIView. That works fine. I am simply trying to send a message to a reference of the layer so the Cocos2d CCLayer can receive the message. This seems simple and I'd think should work. I created a CCLayer pointer called "cocos" as an iVar and set it as this after creating the cocos view:
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]];
CCScene*tempscene=[[CCDirector sharedDirector] runningScene];
cocos=[tempscene.children objectAtIndex:0];
As this is a simple little test app with just one scene and layer, it should work. But the iVar cocos
doesn't respond to any of the public methods in HelloWorldLayer
. Any idea why?
UPDATE: I got it to work by simply re-arranging the code a bit. Not sure why it worked this way and not the prior way:
CCScene*tempscene=[HelloWorldLayer scene];
[[CCDirector sharedDirector] runWithScene: tempscene];
cocos=[tempscene.children objectAtIndex:0];