fixed #1516: The font size of labels for displaying FPS,SPF,DrawCount is incorrect in different design resolutions.

This commit is contained in:
James Chen 2012-10-18 15:53:08 +08:00
parent d68f7c76f6
commit 549dd92d8e
2 changed files with 8 additions and 9 deletions

View File

@ -775,20 +775,21 @@ void CCDirector::createStatsLabel()
m_pDrawsLabel = new CCLabelAtlas();
m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.');
*/
m_pFPSLabel = CCLabelTTF::create("00.0", "Arial", 24);
int fontSize = (int)(m_obWinSizeInPoints.height / 320.0f * 24);
m_pFPSLabel = CCLabelTTF::create("00.0", "Arial", fontSize);
m_pFPSLabel->retain();
m_pSPFLabel = CCLabelTTF::create("0.000", "Arial", 24);
m_pSPFLabel = CCLabelTTF::create("0.000", "Arial", fontSize);
m_pSPFLabel->retain();
m_pDrawsLabel = CCLabelTTF::create("000", "Arial", 24);
m_pDrawsLabel = CCLabelTTF::create("000", "Arial", fontSize);
m_pDrawsLabel->retain();
//CCTexture2D::setDefaultAlphaPixelFormat(currentFormat);
CCSize contentSize = m_pDrawsLabel->getContentSize();
m_pDrawsLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2 + 40), CC_DIRECTOR_STATS_POSITION));
m_pDrawsLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height*5/2), CC_DIRECTOR_STATS_POSITION));
contentSize = m_pSPFLabel->getContentSize();
m_pSPFLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2 + 20), CC_DIRECTOR_STATS_POSITION));
m_pSPFLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height*3/2), CC_DIRECTOR_STATS_POSITION));
contentSize = m_pFPSLabel->getContentSize();
m_pFPSLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2), CC_DIRECTOR_STATS_POSITION));
}

View File

@ -87,12 +87,10 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, Resol
m_eResolutionPolicy = resolutionPolicy;
//setViewPortInPoints(0, 0,m_obScreenSize.width, m_obScreenSize.height);
// reset director's member variables to fit visible rect
CCDirector::sharedDirector()->createStatsLabel();
// reset director's member variables to fit visible rect
CCDirector::sharedDirector()->m_obWinSizeInPoints = getSize();
CCDirector::sharedDirector()->m_obWinSizeInPixels = CCSizeMake(m_obDesignResolutionSize.width*CC_CONTENT_SCALE_FACTOR(), m_obDesignResolutionSize.height*CC_CONTENT_SCALE_FACTOR());
CCDirector::sharedDirector()->createStatsLabel();
CCDirector::sharedDirector()->setGLDefaultValues();
}