I need to create a timer that has hour, mins, and seconds
I currently have code that can display mins and seconds. But the problem I'm facing is that when the mins gets to 60, it cou开发者_JAVA百科nts up to 61 and beyond.
How can I add the hours?
-(void)update:(ccTime)dt{
totalTime += dt;
currentTime = (int)totalTime;
if (myTime < currentTime)
{
myTime = currentTime;
[countUpTimer setString:[NSString stringWithFormat:@"%02d:%02d", myTime/60, myTime%60]];
}
}
[countUpTimer setString:[NSString stringWithFormat:@"%02d:%02d:%02d", myTime/3600, (myTime/60)%60, myTime%60]];
精彩评论