0
我想创建一个容器视图的Kobold2D应用程序,该容器视图将同时容纳cocos2d CCDirector视图和我自己的UIViews。我可以从文档中看到,这可以使用AppDelegate中的alternateView方法完成,但我看不到如何使用此方法以及它应该返回的内容。你能给我一个例子吗?如何在Kobold2D中使用AppDelegate alternateView替换rootViewController
我想创建一个容器视图的Kobold2D应用程序,该容器视图将同时容纳cocos2d CCDirector视图和我自己的UIViews。我可以从文档中看到,这可以使用AppDelegate中的alternateView方法完成,但我看不到如何使用此方法以及它应该返回的内容。你能给我一个例子吗?如何在Kobold2D中使用AppDelegate alternateView替换rootViewController
它应该只是返回一个UIView。该“的Cocos2D与UIKit的意见”模板工程采用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
感谢斯特芬。作为Kobold2D的新手,有时候“明显”并不明显。现在我可以看到真正有用的结构。 –
再次嗨。我试过把这段代码放到alternateView中,并在其中放置一个断点,但它看起来像函数永远不会被调用。是否有需要设置以确保alternateView被调用的开关/配置? –
嗨保罗,你有没有找到解决方案? – user810395