Cocos2d与UIKit视图整合开发全解析
1. 在Cocos2d中添加UIKit文本框
在Cocos2d项目里添加UIKit视图,操作相对简单。在 addSomeCocoaTouch 方法末尾添加如下代码,要确保将 textFieldFront 添加为 dummyView 的子视图,而非 glView 的子视图:
UITextField* textFieldFront = [[UITextField alloc] initWithFrame:
CGRectMake(280, 40, 200, 24)];
textFieldFront.text = @" On top of Cocos2D";
textFieldFront.borderStyle = UITextBorderStyleRoundedRect;
textFieldFront.delegate = self;
[dummyView addSubview:textFieldFront];
[textFieldFront release];
实际上,也能把 textFieldFront 作为子视图添加到 glView 中,短期内不会有明显变化。不过,将文本框添加到 dummyView ,就能随时在视图层次结构中重新排序。例如,可使用 dummyView 的 sendSubviewTo
超级会员免费看
订阅专栏 解锁全文
28

被折叠的 条评论
为什么被折叠?



