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