0
votes

I want to run a cocos2D scene on a UIView, called camera_view.

So I try adding the camera_view to the openGLView :

[[CCDirector sharedDirector].openGLView addSubview:cameraView];

And then push my scene, called scene :

[[CCDirector sharedDirector] pushScene: scene];

But after doing that, I can only see the UIView, and the cocos2D scene is no longer visible. However, before adding the camera_view as a subview of the openGLView, the scene was working absolutely fine.

How can I fix this issue ?

Thanks.

1
Everything drawn by Cocos2D is drawn directly on the EAGLView, not with views (as normally is with UIKit) but with OpenGL calls. So I think it is not possible to add subviews below any CCNode. I mean that the subviews will always appear above. - Ricard Pérez del Campo

1 Answers

0
votes

My solution is as follows :

I added my camera_view and the openGLView, each as a subview of the UIWindow :

[window addSubview: camera_view];
[window addSubView: [CCDirector sharedDirector].openGLView];

Then I pushed the cocos2D scene :

[[CCDirector sharedDirector] pushScene: scene];

And that solved the problem. Now I can view the cocos2D scene on my UIView.