【发布时间】:2011-12-13 21:21:33
【问题描述】:
我想添加一个指令页面,其中的指令是用 UITextView 编写的。如何在 Cocos2d 中做到这一点。因为这是一个游戏页面,我想拿cocos2d的菜单交易效果,比如CCTransitionRadialCCW。
我写了这段代码
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10,60, 300,360)];
textView.backgroundColor = [UIColor clearColor];
textView.text = @"I am First enemy";
[textView setEditable:NO];
[[[CCDirector sharedDirector]openGLView]addSubview:textView];
但是在我写这段代码的时候,它被添加到主CCDirector页面有问题
// [[[CCDirector sharedDirector]openGLView]addSubview:textView];
// replaced by :-
[self addChild:textView];
它给了我错误。请告诉我如何在 CCScene 或 CCLayer 中添加 UITextView。
我知道 [self addChild:(CCNode *)node];
addChild: 方法需要 CCNode,所以请告诉我如何将 UITextView 对象类型转换或转换为 CCNode。
如果有一些替代选项请告诉我。就像 CCLabelTTF 是 UILabel 的替代品,在 Cocos2d-iphone 中是否有 UITableView 的替代品。
提前致谢
【问题讨论】:
标签: iphone ios cocos2d-iphone