Hi all,
I’m trying to add a stopwatch to my newly created hud layer. I have implemented it like this:
//Create HUD HudScene* hudLayer = HudScene::node(); CC_BREAK_IF(! hudLayer); this->addChild(hudLayer,2);
In my HUD layer scene i’d like to create a timer that increments in seconds? mm:ss < like this.
Could anyone make any suggestions?
Thanks,
Dean
You can do that easily using schedule.
I think i’ve cracked it.
`void HudScene::drawHud()
{
// Create a label and initialize with string “Time”.
CCLabelBMFont* timeLabel = CCLabelBMFont::create(“Time”,“matf.fnt”,150,kCCTextAlignmentLeft);
timeLabel->setPosition(CCDirector::sharedDirector()->getWinSize().width - 200, CCDirector::sharedDirector()->getWinSize().height - 30);
this->addChild(timeLabel,1);
//Create a label integer for time
levelTime = CCLabelBMFont::create(“0”,“matf.fnt”,150,kCCTextAlignmentLeft);
levelTime->setPosition(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2);
this->addChild(levelTime, 5);
}
void HudScene::update(float dt)
{
time = time + dt;
levelTime->setString(CCString::stringWithFormat("%d",time)); <-- Can’t get this line to work.
}`
I can’t set the string at all! 
CCString::createWithFormat(“%d”,time)
void HudScene::update(float dt) { time = time + dt; levelTime->setString(CCString::createWithFormat("%d",time)); }
void HudScene::update(float dt) { time = time + dt; CCString* updateTime = CCString::createWithFormat("%d",time); levelTime->setString(updateTime); }
Tried these ways. I can’t get it to work. 
EDIT:
Got it working, has to use this.
levelTime->setString(updateTime->getCString());