issue #1156: remove unneeded macros and functions

This commit is contained in:
minggo 2012-04-13 11:45:41 +08:00
parent 028cf7874e
commit 9bbac0d33d
3 changed files with 40 additions and 72 deletions

View File

@ -99,7 +99,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
// pDirector->enableRetinaDisplay(true); // pDirector->enableRetinaDisplay(true);
// turn on display FPS // turn on display FPS
//pDirector->setDisplayFPS(true); pDirector->setDisplayStats(true);
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);

View File

@ -586,43 +586,6 @@ void CCDirector::end()
m_bPurgeDirecotorInNextLoop = true; m_bPurgeDirecotorInNextLoop = true;
} }
void CCDirector::resetDirector()
{
// don't release the event handlers
// They are needed in case the director is run again
m_pTouchDispatcher->removeAllDelegates();
if (m_pRunningScene)
{
m_pRunningScene->onExit();
m_pRunningScene->cleanup();
m_pRunningScene->release();
}
m_pRunningScene = NULL;
m_pNextScene = NULL;
// remove all objects, but don't release it.
// runWithScene might be executed after 'end'.
m_pobScenesStack->removeAllObjects();
stopAnimation();
CCObject* pProjectionDelegate = (CCObject*)m_pProjectionDelegate;
CC_SAFE_RELEASE_NULL(pProjectionDelegate);
// purge bitmap cache
CCLabelBMFont::purgeCachedData();
// purge all managers
CCAnimationCache::purgeSharedAnimationCache();
CCSpriteFrameCache::purgeSharedSpriteFrameCache();
CCTextureCache::purgeSharedTextureCache();
CCShaderCache::purgeSharedShaderCache();
}
void CCDirector::purgeDirector() void CCDirector::purgeDirector()
{ {
// don't release the event handlers // don't release the event handlers
@ -655,15 +618,20 @@ void CCDirector::purgeDirector()
// purge bitmap cache // purge bitmap cache
CCLabelBMFont::purgeCachedData(); CCLabelBMFont::purgeCachedData();
// purge all managers // purge all managers caches
CCAnimationCache::purgeSharedAnimationCache(); CCAnimationCache::purgeSharedAnimationCache();
CCSpriteFrameCache::purgeSharedSpriteFrameCache(); CCSpriteFrameCache::purgeSharedSpriteFrameCache();
CCTextureCache::purgeSharedTextureCache(); CCTextureCache::purgeSharedTextureCache();
CCShaderCache::purgeSharedShaderCache(); CCShaderCache::purgeSharedShaderCache();
// cocos2d-x specific data structures
CCUserDefault::purgeSharedUserDefault(); CCUserDefault::purgeSharedUserDefault();
CCNotificationCenter::purgeNotifCenter(); CCNotificationCenter::purgeNotifCenter();
ccGLInvalidateStateCache(); ccGLInvalidateStateCache();
CHECK_GL_ERROR_DEBUG();
// OpenGL view // OpenGL view
m_pobOpenGLView->release(); m_pobOpenGLView->release();
m_pobOpenGLView = NULL; m_pobOpenGLView = NULL;
@ -746,25 +714,28 @@ void CCDirector::showStats(void)
if (m_bDisplayStats) if (m_bDisplayStats)
{ {
if (m_fAccumDt > CC_DIRECTOR_STATS_INTERVAL && m_pFPSLabel && m_pSPFLabel && m_pDrawsLabel) if (m_pFPSLabel && m_pSPFLabel && m_pDrawsLabel)
{ {
sprintf(m_pszFPS, "%.3f", m_fSecondsPerFrame); if (m_fAccumDt > CC_DIRECTOR_STATS_INTERVAL)
m_pFPSLabel->setString(m_pszFPS); {
sprintf(m_pszFPS, "%.3f", m_fSecondsPerFrame);
m_pFPSLabel->setString(m_pszFPS);
m_fFrameRate = m_uFrames / m_fAccumDt;
m_uFrames = 0;
m_fAccumDt = 0;
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
m_pFPSLabel->setString(m_pszFPS);
sprintf(m_pszFPS, "%4d", g_uNumberOfDraws);
m_pDrawsLabel->setString(m_pszFPS);
}
m_fFrameRate = m_uFrames / m_fAccumDt; m_pDrawsLabel->visit();
m_uFrames = 0; m_pFPSLabel->visit();
m_fAccumDt = 0; m_pSPFLabel->visit();
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
m_pFPSLabel->setString(m_pszFPS);
sprintf(m_pszFPS, "%4d", g_uNumberOfDraws);
m_pDrawsLabel->setString(m_pszFPS);
} }
m_pDrawsLabel->draw();
m_pFPSLabel->draw();
m_pSPFLabel->draw();
} }
g_uNumberOfDraws = 0; g_uNumberOfDraws = 0;
@ -780,23 +751,21 @@ void CCDirector::calculateMPF()
void CCDirector::createStatsLabel() void CCDirector::createStatsLabel()
{ {
if( m_pFPSLabel && m_pSPFLabel ) { CC_SAFE_RELEASE_NULL(m_pFPSLabel);
CCTexture2D *texture = m_pFPSLabel->getTexture(); CC_SAFE_RELEASE_NULL(m_pSPFLabel);
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
m_pFPSLabel->release();
m_pSPFLabel->release();
CCTextureCache::sharedTextureCache()->removeTexture(texture);
m_pFPSLabel = NULL;
m_pSPFLabel = NULL;
}
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 20); m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "Arial", 16);
m_pSPFLabel = CCLabelTTF::labelWithString("0.000", "Arial", 20); m_pSPFLabel = CCLabelTTF::labelWithString("0.000", "Arial", 16);
m_pDrawsLabel = CCLabelTTF::labelWithString("000", "Arial", 20); m_pDrawsLabel = CCLabelTTF::labelWithString("000", "Arial", 16);
m_pDrawsLabel->setPosition(ccpAdd(ccp(0, 34), CC_DIRECTOR_STATS_POSITION)); m_pFPSLabel->retain();
m_pSPFLabel->setPosition(ccpAdd(ccp(0, 17), CC_DIRECTOR_STATS_POSITION)); m_pSPFLabel->retain();
m_pFPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION); m_pDrawsLabel->retain();
m_pDrawsLabel->setPosition(ccp(20, 50));
m_pSPFLabel->setPosition(ccp(25, 30));
m_pFPSLabel->setPosition(ccp(20, 10));
} }

View File

@ -335,7 +335,6 @@ public:
/** returns a shared instance of the director */ /** returns a shared instance of the director */
static CCDirector* sharedDirector(void); static CCDirector* sharedDirector(void);
void resetDirector();
protected: protected: