0
votes

I want to add a UiView on the CCDirector and a scene on that UIView. Actually i have some custom Cocoa touch control and that i want to use in my game and above that i need a scene.

Currently i am doing like this.

[[[CCDirector sharedDirector] openGLView] addSubview:gridViewController.view]; and after that line i do [[CCDirector sharedDirector] runWithScene:[MYScene scene]];

[MYScene scene] returns a CCScene instance.

But what happens that on my custom cocoa touch control is visible but my scene is not visible at all.

Can any one guide me for that how i can accomplish my task.

1

1 Answers

0
votes

You should try the opposite approach and have the UIView handled as a CCNode, then add the node to the scene.

There is even a class that makes this easily possible: CCUIViewWrapper. If you use it, you can do the following:

CCUIViewWrapper* wrapper = [CCUIViewWrapper wrapperForUIView:view];
wrapper.contentSize = view.frame.size;
[self addChild:wrapper z:1 tag:LayerTagUILayer];

and you will get both the UIView and the scene added to CCDirector.glView. The UIView can be any, you can even define it in IB.