add code to show FPS and particle count
This commit is contained in:
natural-law 2010-08-25 05:45:28 +00:00
parent 8c818ac0ff
commit 4a42f2d334
3 changed files with 15 additions and 11 deletions

View File

@ -726,6 +726,8 @@ void CCDirector::showFPS(void)
m_pFPSLabel->setString(str);
delete [] str;
}
m_pFPSLabel->draw();
}
#endif // CC_DIRECTOR_FAST_FPS

View File

@ -32,8 +32,10 @@ Ttest_uphoneApp::~Ttest_uphoneApp()
bool Ttest_uphoneApp::initCocos2d()
{
// init director
CCDirector::getSharedDirector()->setOpenGLView(m_pMainWnd);
CCDirector::getSharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
CCDirector * pDirector = CCDirector::getSharedDirector();
pDirector->setOpenGLView(m_pMainWnd);
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
pDirector->setDisplayFPS(true);
// load background image texture and get window size
CCTexture2D * pTexture = CCTextureCache::sharedTextureCache()->addImage("/NEWPLUS/TDA_DATA/UserData/HelloWorld.png");

View File

@ -723,8 +723,8 @@ ParticleDemo::ParticleDemo(void)
addChild( menu, 100 );
CCLabel* labelAtlas = CCLabel::labelWithString("0000", "fonts", 16);
addChild(labelAtlas, 100, kTagLabelAtlas);
CCLabelAtlas* labelAtlas = CCLabelAtlas::labelAtlasWithString("0000", "fps_images.png", 16, 24, '.');
addChild(labelAtlas, 100, kTagLabelAtlas);
labelAtlas->setPosition( CGPointMake(254,50) );
// moving background
@ -785,13 +785,13 @@ void ParticleDemo::ccTouchEnded(CCTouch* touch, UIEvent* event)
void ParticleDemo::step(ccTime dt)
{
// CCLabel* atlas = (CCLabel*)getChildByTag(kTagLabelAtlas);
//
// char str[5] = {0};
// //std::string str;
// sprintf(str, "%4d", m_emitter->getParticleCount());
// //str.format("%4d", m_emitter->getParticleCount());
// atlas->setString(str);
if (m_emitter)
{
CCLabelAtlas* atlas = (CCLabelAtlas*)getChildByTag(kTagLabelAtlas);
char str[5] = {0};
sprintf(str, "%04d", m_emitter->getParticleCount());
atlas->setString(str);
}
}
void ParticleDemo::toggleCallback(NSObject* pSender)