CCUIViewWrapperを使用
以下のURLよりソースを取得
※そのままではBuild時に警告が出るので以下を修正
[[[[CCDirector sharedDirector] view] window] addSubview: uiItem]; //[[[CCDirector sharedDirector] openGLView] addSubview:uiItem]; /****************************************/ //if(!p.isRelativeAnchorPoint) if(p.ignoreAnchorPointForPosition) transform = CGAffineTransformTranslate(transform, p.anchorPoint.x, p.anchorPoint.y); //transform = CGAffineTransformTranslate(transform, p.anchorPointInPixels.x, p.anchorPointInPixels.y); /****************************************/ transform = CGAffineTransformTranslate(transform, -p.anchorPoint.x, -p.anchorPoint.y); //transform = CGAffineTransformTranslate(transform, -p.anchorPointInPixels.x, -p.anchorPointInPixels.y);
UITextFieldを実装
ヘッダー
@interface GameLayer : CCLayer <UITextFieldDelegate> { CCUIViewWrapper *textFieldWrapper; UITextField *textBox; } @end
実装
- (void)addTextField { textBox = [[[UITextField alloc] init] autorelease]; textBox.frame = CGRectMake(175, 120, 110, 25); textBox.borderStyle = UITextBorderStyleRoundedRect; textBox.placeholder = @"hogehoge"; textBox.returnKeyType = UIReturnKeyDone; textBox.clearButtonMode = UITextFieldViewModeWhileEditing; textBox.autocapitalizationType = UITextAutocapitalizationTypeNone; textBox.enablesReturnKeyAutomatically = YES; textBox.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter; textBox.textAlignment = NSTextAlignmentCenter; textFieldWrapper = [CCUIViewWrapper wrapperForUIView:textBox]; textBox.delegate = self; [self addChild:textFieldWrapper]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } - (void)textFieldDidEndEditing:(UITextField *)textField { CCLOG(@"text->%@", textBox.text); }
0 件のコメント:
コメントを投稿