我想添加一個指令頁面,其中的指令寫在UITextView中。如何在Cocos2d中做到這一點。因爲這是一個遊戲頁面,我想要像CCTransitionRadialCCW一樣採用cocos2d的菜單事務效果。如何在CCLayer或CCScene中添加UITextView在cocos2d-iphone
我寫了這個代碼
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,有替代UITableView在Cocos2d iphone。
在此先感謝