views:

23

answers:

1

Hello, I need a counter that updates a CCLabel every second. I want it so the user can see how long they survived. I'm not totally sure how to explain this so let me know if I can make things clearer.

+1  A: 

Why not use timer ?

[NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES]

-(void)updateLabel:(NSTimer*)t
{
  //Your code here
}

or in your render method you could check how many time has passed and update label accordingly, you can use for example code like this:

when launching game ( remember to release it when done with it):

gameStartDate = [[NSDate date] retain];

in draw method

[[NSDate date] timeIntervalSinceDate: gameStartDate];
//! update label code

For game I would probably use second option but both should suffice

Cheers, Krzysztof Zabłocki

Krzysztof Zabłocki
Thanks but I figured it out!
allthewayapps