Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2013 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5349920 to your computer and use it in GitHub Desktop.
Save anonymous/5349920 to your computer and use it in GitHub Desktop.
void CCDirector::createStatsLabel()
{
if( m_pFPSLabel && m_pSPFLabel )
{
//CCTexture2D *texture = m_pFPSLabel->getTexture();
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
CC_SAFE_RELEASE_NULL(m_pSPFLabel);
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
// CCTextureCache::sharedTextureCache()->removeTexture(texture);
CCFileUtils::sharedFileUtils()->purgeCachedEntries();
}
/*
CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat();
CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
m_pFPSLabel = new CCLabelAtlas();
m_pFPSLabel->initWithString("00.0", "fps_images.png", 12, 32, '.');
m_pSPFLabel = new CCLabelAtlas();
m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.');
m_pDrawsLabel = new CCLabelAtlas();
m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.');
*/
int fontSize = 0;
if (m_obWinSizeInPoints.width > m_obWinSizeInPoints.height)
{
fontSize = (int)(m_obWinSizeInPoints.height / 320.0f * 24);
}
else
{
fontSize = (int)(m_obWinSizeInPoints.width / 320.0f * 24);
}
m_pFPSLabel = CCLabelTTF::create("00.0", "Arial", fontSize);
m_pFPSLabel->retain();
m_pSPFLabel = CCLabelTTF::create("0.000", "Arial", fontSize);
m_pSPFLabel->retain();
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*5/2), CC_DIRECTOR_STATS_POSITION));
contentSize = m_pSPFLabel->getContentSize();
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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment