0

我想创建一个包含 cocos2d CCDirector 视图和我自己的 UIViews 的容器视图的 Kobold2D 应用程序。我可以从文档中看到,这可以使用 AppDelegate 中的 alternateView 方法来完成,但我看不到如何使用此方法以及它应该返回什么。你能给我举个例子吗?

4

1 回答 1

1

它应该简单地返回一个 UIView。“Cocos2D with UIKit Views”模板项目使用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 回答