2012-08-17 64 views
0

我想繪製一個NSString,但它不會呈現出於某種原因。NSString沒有繪圖?

- (void)renderScene { 
    // Make sure we are renderin to the frame buffer 
    [EAGLContext setCurrentContext:context]; 

    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); 

    // Clear the color buffer with the glClearColor which has been set  
    glClear(GL_COLOR_BUFFER_BIT); 

    //Render the game Scene 
    if(gameState == 0){ 

     //MENU 
     [menu renderAtPoint: CGPointMake(0, 0) centerOfImage: NO]; 

    } else if(gameState == 1){ 

     //GAMEPLAY 

     [bk renderAtPoint: CGPointMake(0, 0) centerOfImage: NO]; 

     [self drawScore]; 

     [player draw]; 

     [squares render]; 

     [scoreString drawAtPoint: CGPointMake(262, 250) withFont:[UIFont fontWithName:@"TimesNewRoman" size: 1.0f]]; //RIGHT HERE IS THE DRAW STRING 

    } else if(gameState ==2){ 

     //DEATH SCREEN 

     [squared renderAtPoint: CGPointMake(0, 0) centerOfImage: NO]; 

    } 

回答

0

您正在嘗試混合使用Core Graphics和OpenGL。解決這個問題的一個簡單方法是創建一個子窗口(UIView或UILabel),然後在子窗口中設置文本字符串。您也可以設置子視圖的透明度。還有其他方法(如繪製位圖,然後將其用作OpenGL紋理,或使用OpenGL將字體繪製爲位圖或輪廓),但它們更加有效 - 取決於您的需求。