2014-01-24 4 views
0

Я новичок в cocos2d.Я занимаюсь игрой с uiview с платформой cocos2d (3.0 Beta). Я устанавливаю GLView в пользовательский viewcontroller. Ниже мой код.GlView вызывает ошибку OpenGL

- (void)setupCocos2D { 

     CCGLView *glView = [CCGLView viewWithFrame:self.view.bounds pixelFormat:kEAGLColorFormatRGB565 depthFormat:0];** 

     glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

     [self.view insertSubview:glView atIndex:0]; 

     [[CCDirector sharedDirector] setView:glView];** 

    } 

Он работает fine.But, когда мы помещаем на объекте, то дайте мне После Worning памяти.

OpenGL error 0x0506 in -[CCSprite draw] 544 
OpenGL error 0x0502 in -[CCGLView swapBuffers] 287** 

Я думаю, когда мы называем ([[CCDirector sharedDirector] setView:glView]) метод setView это не найти метод CCDirector но UIView method.I не может получить доступ к CCDirector method.Same Метод Я также не могу назвать в классе AppDelegate.

- (void)applicationWillTerminate:(UIApplication *)application { 

    CCDirector *director = [CCDirector sharedDirector]; 

    //openGLView is now (setView in Latest version).It's Can't Access here.** 

    [[director openGLView] removeFromSuperview]; 
    [director end]; 
} 
+0

что это ошибка OpenGL, а не предупреждение памяти. То, что вы делаете для настройки cocos2d, совсем не выглядит правильным. Я не думаю, что авторезистентность еще не подтверждена. Знаете ли вы, что директор является контролером? – LearnCocos2D

+0

@ LearnCocos2D ошибка ya.it's opengl. Мне не нужна Autorisizing.every вещь отображается отлично. Но когда мы добавляем объект спрайта, тогда генерируется ошибка. Некоторое время Производительность так сильно уменьшается. Я не тестировался на устройстве. Thanx для вашего воспроизведения. –

+0

@ LearnCocos2D мой код работает отлично в 2.0, но не работает в версии 3.0. –

ответ

0

используется код, приведенный ниже в setupCocos2D

- (void)setupCocos2D 
{ 
    [[CCDirector sharedDirector] end]; 

    UIWindow *window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 


    [window_ setBackgroundColor:[UIColor whiteColor]]; 


    CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds] 
            pixelFormat:kEAGLColorFormatRGB565 
            depthFormat:0 
          preserveBackbuffer:NO 
            sharegroup:nil 
           multiSampling:NO 
           numberOfSamples:0]; 

    director_ = (CCDirectorIOS*) [CCDirector sharedDirector]; 

    director_.wantsFullScreenLayout = YES; 

    // Display FSP and SPF 
    [director_ setDisplayStats:NO]; 

    // set FPS at 60 
    [director_ setAnimationInterval:1.0/60]; 

    // attach the openglView to the director 
    [director_ setView:glView]; 

    // 2D projection 
    [director_ setProjection:kCCDirectorProjection2D]; 



    // [director setProjection:kCCDirectorProjection3D]; 

    // 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"); 

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images 
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 
    // You can change this setting at any time. 
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; 

    CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils]; 
    [sharedFileUtils setEnableFallbackSuffixes:NO];    // Default: NO. No fallback suffixes are going to be used 
    [sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];  // Default on iPhone RetinaDisplay is "-hd" 
    [sharedFileUtils setiPadSuffix:@"-ipad"];     // Default on iPad is "ipad" 
    [sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd" 

    // Assume that PVR images have premultiplied alpha 
    [CCTexture2D PVRImagesHavePremultipliedAlpha:YES]; 


} 
+0

Я пробовал этот. Мой проект отлично работает в 2.0, но не работает в последних версиях cocos2d 3.0 Альфа-версия. –

Смежные вопросы