cocos2d CCDirector ビューと独自の UIView の両方を保持するコンテナー ビューを持つ Kobold2D アプリを作成したいと考えています。ドキュメントから、これは AppDelegate の alternateView メソッドを使用して実行できることがわかりますが、このメソッドの使用方法と正確に何を返す必要があるかはわかりません。例を挙げていただけますか?
1 に答える
1
単純に UIView を返す必要があります。「UIKit ビューを持つ Cocos2D」テンプレート プロジェクトは、alternateView メソッドを使用して、まさにこの種類のコンテナー ビューを作成します。
@implementation AppDelegate
-(id) alternateView
{
// we want to be a dummy view the self.view to which we add the glView plus all other UIKit views
KKAppDelegate* appDelegate = (KKAppDelegate*)[UIApplication sharedApplication].delegate;
// add a dummy UIView to the view controller, which in turn will have the glView and later other UIKit views added to it
CGRect bounds = [appDelegate.window bounds];
UIView* dummyView = [[UIView alloc] initWithFrame:bounds];
[dummyView addSubview:[CCDirector sharedDirector].view];
return dummyView;
}
@end
このコードは、プロジェクトのAppDelegate.mに入ります
于 2012-09-20T12:53:37.300 に答える