Put the UIView onto cocos2d-iphone CCLayer
@interface UIKitLayer : CocosNode { UIView * pView; } -(void) addChild : (UIView *) subView; -(void) setFrame : (CGRect) frame; -(void) setBackgroundColor : (UIColor *)color; @end @implementation UIKitLayer -(id) init { self = [super init]; pView = [[UIView alloc]initWithFrame : CGRectMake(0,0,1,1)]; [pView setBackgroundColor: [UIColor clearColor]]; [pView setCenter: cpv(0,0)]; [super setPosition: cpv(0,0)]; [[[Director sharedDirector] openGLView] addSubview:pView]; NSLog(@"pView inserted"); return self; } -(void) dealloc { if(pView) { NSLog(@"pView deallocing"); [pView removeFromSuperview]; [pView release]; } [super dealloc]; } -(void) addChild : (UIView *) subView { NSAssert(pView,@"subView must be valid"); [pView addSubview: subView]; } -(void) setVisible : (bool) agv { super.visible = agv; pView.hidden = !agv; } -(void) setPosition : (CGPoint) point { [super setPosition: point]; [pView setCenter: point]; } -(void) setFrame : (CGRect) frame { [pView setFrame: frame]; } -(void) setBackgroundColor : (UIColor *)color { [pView setBackgroundColor: color]; } @end
Log in to answer.
leothenerd 12:19 pm on December 19, 2009