开发者

how to integrate UIViewcontroller in a cocos2d scene

am having开发者_C百科 uiviewcontroller for some effects using in camera.

am using cocos2d lot for this project. i want just how to integrate this UIviewcontroller in cocos2d scene.

using uiviewwrapper for UIview integration

same as for UIview controller any wrapper is there ?

thanks in advance.


in MyViewController.h

add MyViewController *mviewController;

in MyViewcontroller.m

#import "MyViewcontroller.h"


//before push mviewController 

    if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
        [CCDirector setDirectorType:kCCDirectorTypeDefault];


    CCDirector *director = [CCDirector sharedDirector];

    mviewController = [[MyViewcontroller alloc] initWithNibName:nil bundle:nil];
    mviewController.wantsFullScreenLayout = YES;



    EAGLView *glView = [EAGLView viewWithFrame:[[UIScreen mainScreen] bounds]
                                   pixelFormat:kEAGLColorFormatRGB565   // kEAGLColorFormatRGBA8
                                   depthFormat:0                        // GL_DEPTH_COMPONENT16_OES
                        ];

    // attach the openglView to the director
    [director setOpenGLView:glView];

//  // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
//  if( ! [director enableRetinaDisplay:YES] )
//      CCLOG(@"Retina Display Not supported");

#if GAME_AUTOROTATION == kGameAutorotationUIViewController
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif

    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:YES];


    // make the OpenGLView a child of the view controller
    [mviewController setView:glView];

    [[CCDirector sharedDirector]replaceScene:[NewLayer scene]];


//here push that viewController

if u dont want to create new viewcontroller then u can useable simply

[[CCDirector sharedDirector]replaceScene:[NewLayer scene]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜