0

您好我正在尝试将 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];
}

请问有什么建议吗?

4

0 回答 0