как интегрировать UIViewcontroller в сцену cocos2d - PullRequest
4 голосов
/ 25 июня 2011

У меня uiviewcontroller для некоторых эффектов, используемых в камере.

Я использую лотос cocos2d для этого проекта.Я просто хочу, как интегрировать этот UIviewcontroller в cocos2d сцене.

с использованием uiviewwrapper для интеграции UIview

Так же, как для контроллера UIview, есть какая-нибудь обертка?

заранее спасибо.

1 Ответ

4 голосов
/ 25 июня 2011

в MyViewController.h

добавить MyViewController * mviewController;

в 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

если вы не хотите создавать новый viewcontroller, тогда вы можете использовать его просто

[[CCDirector sharedDirector]replaceScene:[NewLayer scene]];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...