Hello, i would like to make a timer in the scene.
I couldnt find any solution how to.
I heard that using cocoas NSTimer isnt recommended.
So how do you schedule every second Count++; setString %,Count?
A fast, easy to use, free, and community supported 2D game engine
Hello, i would like to make a timer in the scene.
I couldnt find any solution how to.
I heard that using cocoas NSTimer isnt recommended.
So how do you schedule every second Count++; setString %,Count?
up?
Yes, there i need to use scheduled instead NSTimer. But there is problem, the result of timer is not 1..2.3... seconds, but Time: 0 changing with 0 -...
timeLabel = [[CCLabel labelWithString:[NSString stringWithFormat:@"Time: 0"] dimensions:CGSizeMake(130, 25) alignment:UITextAlignmentCenter fontName:@"Arial" fontSize:20.0] retain];
[self schedule:@selector(timer:)];
-(void)timer:(ccTime)dt
{
ccTime count;
count +=dt;
[timeLabel setString:[NSString stringWithFormat:@"Time: %i",count]];
}
Why my script is not working properly?
ccTime is a float, not an integer
So i use int count; and it is not counting. I dont know where is problem. Do u have some examples of count++ time?
tests/IntervalTest.m
Works fine, thanks.
You must log in to post.