Search code examples
cocos2d-xcocos2d-x-3.0

How can we display Time in our Game cocos2dx


I tried to use :

DelayTime* Second Schedule() function

but nothing happened.

I just want to display my time in HUD Layer.

Thanks in Advance...


Solution

  • Update a time variable in a scheduled function with 1 second delay. Make a counter increase on each call of the function and calculate time like following:

    HH = Counter /3600;
    MM = (Counter %3600)/60;
    SS: ((counter%3600)%60);