Reputation: 5334
I am using CCUIViewWrapper
Class to add UIControl
in Cocos2d.
Here is my code,
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
view.backgroundColor=[UIColor greenColor];
CCUIViewWrapper *Wrapper = [CCUIViewWrapper wrapperForUIView:view];
[self addchild:Wrapper];
Afte I am adding CCLabelTTF
CCLabelTTF * label=[CCLabelTTF labelWithString:@"Hi" fontName:@"Marker Felt" fontSize:32];
label.position=ccp(160,280);
[self addChild:label];
So, my problem is that the label does not appear.
I am also trying to change zOrder & also trying to insertSubviewatIndex
.
Upvotes: 1
Views: 652
Reputation: 64478
If you make a fullscreen UIKit view, it will be drawn over the cocos2d view. If that view is opaque, you won't see any of the cocos2d view.
By making the cocos2d view transparent (opaque = NO), setting the OpenGL clear color to alpha = 0 and changing the framebuffer to 32-Bit with alpha, you can also add UIKit views that are drawn behind the cocos2d view and its nodes.
You can not have the same UIKit view both in front of some cocos2d nodes and behind other cocos2d nodes at the same time. It's simply not possible. For example, this draw order can not be done:
You have to consider the cocos2d view with all the nodes in it as a whole (z order only affects how cocos2d nodes are drawn in relation to each other). The cocos2d view can be either completely in front or completely behind a UIkit view.
Upvotes: 1