diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 52ec198b41..6059c2c8ea 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -816,9 +816,9 @@ void CCDirector::getFPSImageData(unsigned char** datapointer, unsigned int* leng void CCDirector::createStatsLabel() { CCTexture2D *texture = NULL; - CCTextureCache *textureCache = CCTextureCache::sharedTextureCache(); - - if( m_pFPSLabel && m_pSPFLabel ) + CCTextureCache *textureCache = CCTextureCache::sharedTextureCache(); + + if( m_pFPSLabel && m_pSPFLabel ) { CC_SAFE_RELEASE_NULL(m_pFPSLabel); CC_SAFE_RELEASE_NULL(m_pSPFLabel); @@ -830,38 +830,38 @@ void CCDirector::createStatsLabel() CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat(); CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); unsigned char *data = NULL; - unsigned int data_len = 0; - getFPSImageData(&data, &data_len); - + unsigned int data_len = 0; + getFPSImageData(&data, &data_len); + CCImage* image = new CCImage(); bool isOK = image->initWithImageData(data, data_len); if (!isOK) { CCLOGERROR("%s", "Fails: init fps_images"); return; } - + texture = textureCache->addUIImage(image, "cc_fps_images"); CC_SAFE_RELEASE(image); - + float factor = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height / 320.0f; - + m_pFPSLabel = new CCLabelAtlas(); m_pFPSLabel->setIgnoreContentScaleFactor(true); m_pFPSLabel->initWithString("00.0", texture, 12, 32 , '.'); m_pFPSLabel->setScale(factor); - + m_pSPFLabel = new CCLabelAtlas(); m_pSPFLabel->setIgnoreContentScaleFactor(true); m_pSPFLabel->initWithString("0.000", texture, 12, 32, '.'); m_pSPFLabel->setScale(factor); - + m_pDrawsLabel = new CCLabelAtlas(); m_pDrawsLabel->setIgnoreContentScaleFactor(true); m_pDrawsLabel->initWithString("000", texture, 12, 32, '.'); m_pDrawsLabel->setScale(factor); - + CCTexture2D::setDefaultAlphaPixelFormat(currentFormat); - + m_pDrawsLabel->setPosition(ccpAdd(ccp(0, 34*factor), CC_DIRECTOR_STATS_POSITION)); m_pSPFLabel->setPosition(ccpAdd(ccp(0, 17*factor), CC_DIRECTOR_STATS_POSITION)); m_pFPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);