1. CCNode + UIView - (OK)
-(void) addSomeCocoaTouch {
// regular text field with rounded corners
UITextField* textField = [[UITextField alloc] initWithFrame:
CGRectMake(40, 20, 200, 24)];
textField.text = @"Regular UITextField";
textField.borderStyle = UITextBorderStyleRoundedRect;
// get the cocos2d view (it's the EAGLView class which inherits from UIView) U
IView* glView = [CCDirector sharedDirector].openGLView;
// add the text field view to the cocos2d EAGLView
[glView addSubview:textField];
// after that it’s safe to release the textField
[textField release];
}
2. UIView + CCNode - (OK)
(1)
-(void) addSomeCocoaTouch {
// get the cocos2d view (it's the EAGLView class which inherits from UIView) UIView* glView = [CCDirector sharedDirector].openGLView;
// The dummy UIView is the superview of the glView
UIView* superview = glView.superview;
// UITextField initialization code omitted ...
// add the text fields to the dummy view
[superview addSubview:textField];
[superview addSubview:textFieldSkinned];
// send the cocos2d view to the front so it is in front of the other views
[superview bringSubviewToFront:glView];
// make the cocos2d view transparent
glClearColor(0.0, 0.0, 0.0, 0.0);
glView.opaque = NO;
... }
(2)
EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGBA8
depthFormat:0];
(3)
// This will disable all touch events on the cocos2d view
// To enable the touch event of UIView.
glView.userInteractionEnabled = NO;
3. UIView + CCNode + UIView (OK)
4. CCNode + UIView + CCNode (Cannot do this)