Jared
Jared

Reputation: 13

Increase 3 seconds to the timer when the button has been clicked Cocos2d

Sorry this is probably a dumb question but I have been struggling with this for a while. I’m kind of new to Cocos2d, but I have a schedule timer set to 3 secs to make a sprite disappear and every time they click the button it adds 3 seconds to the timer, the problem i'm having is when they click the button it wont add 3 seconds to the timer, the timer just ends,

Upvotes: 1

Views: 108

Answers (3)

Nazik
Nazik

Reputation: 8444

You can also use

[self performSelector:@selector(tick:)withObject:nil afterDelay:3.0];

Upvotes: 0

Harish
Harish

Reputation: 2512

[_timer setFireDate:[[_timer fireDate] dateByAddingTimeInterval:600]];

This would add 10 minutes (600 seconds) to my _timer.

Upvotes: 2

Guru
Guru

Reputation: 22042

In cocos2d, its better to use scheduler instead of NSTimer and you can change fire interval time with following api.

[self schedule: @selector(tick:) interval:0.03f];

[self unschedule:@selector(tick:)];

[self schedule: @selector(tick:) interval:0.05f];

Upvotes: 3

Related Questions