您好我正在尝试将Cocos3D集成到我当前的项目中。
当我在App Delegate中设置包含Cocos3D代码(下面列出)的UIViewControllerCOCOS作为UINavigationController的根时,我可以成功运行它。
但是,如果我使用其他一些viewController说OtherVC并在navigationController上推UIViewControllerCOCOS然后崩溃
_viewController.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll; //APPLICATION CRASH HERE SAYING -[CCDirectorDisplayLink setSupportedInterfaceOrientations:]: unrecognized selector sent to instance 0x146ab0b0. Where
_viewController is CC3DeviceCameraOverlayUIViewController* _viewController;
我使用过Cocos3D hello world代码。
// UIViewControllerCOCOS.m
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self setupCocos3D];
}
-(void)setupCocos3D{
CCTexture2D.defaultAlphaPixelFormat = kCCTexture2DPixelFormat_RGBA8888;
// Establish the view controller and CCDirector (in cocos2d 2.x, these are one and the same)
[self establishDirectorController];
[self.view addSubview:_viewController.view];
// ******** START OF COCOS3D SETUP CODE... ********
// Create the customized CC3Layer that supports 3D rendering.
cc3Layer = [Nabru_cocos3dLayer layerWithController: _viewController];
// Create the customized 3D scene and attach it to the layer.
// Could also just create this inside the customer layer.
cc3Layer.cc3Scene = [Nabru_cocos3dScene scene];
// Assign to a generic variable so we can uncomment options below to play with the capabilities
CC3ControllableLayer* mainLayer = cc3Layer;
_viewController.controlledNode = mainLayer;
// Run the layer in the director
CCScene *scene = [CCScene node];
[scene addChild: mainLayer];
[CCDirector.sharedDirector runWithScene: scene];
}
-(void) establishDirectorController {
_viewController = CC3DeviceCameraOverlayUIViewController.sharedDirector;
_viewController.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll; //APPLICATION CRASH HERE SAYING -[CCDirectorDisplayLink setSupportedInterfaceOrientations:]: unrecognized selector sent to instance 0x146ab0b0. If i comment out this line then it crash second line below it.
_viewController.viewShouldUseStencilBuffer = NO; // Set to YES if using shadow volumes
_viewController.viewPixelSamples = 1; // Set to 4 for antialiasing multisampling
_viewController.animationInterval = (1.0f / kAnimationFrameRate);
_viewController.displayStats = YES;
[_viewController enableRetinaDisplay: YES];
}
有什么建议吗?