Game Clock

Game Clock
0.0 0


So I want to use CCLabelTTF::create() to place a game clock which displays a constantly updating float. I’m new to cocos2d-x and I have no clue how to do this.

I know how to use string stream and certain conversion tools to convert the float into a string, but the function in question apparently doesn’t support strings. Does this function only support const chars, and if so, how would i achieve my goal?


Are you trying to display the elapsed time?

In my step / update function I have something like this.
In my case target time starts at something like 10 seconds.
You could just use elapsedTime

timer is a CCLabelBMFont

    elapsedTime += dt;

    char message[10];
    sprintf(message, "%4.2f", targetTime - elapsedTime);


Thanks, that got me what I needed.