Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSTimer continues running after all tweens have completed #35

Open
jowie opened this issue Jun 12, 2013 · 0 comments
Open

NSTimer continues running after all tweens have completed #35

jowie opened this issue Jun 12, 2013 · 0 comments

Comments

@jowie
Copy link

jowie commented Jun 12, 2013

I have tweaked my local copy so that it invalidates the timer once all tweens have finished, and creates a new timer if needed at the top of addTweenOperation: instead. I believe this is better for large projects such as mine, as it cuts down on the number of instructions happening every second:

- (PRTweenOperation*)addTweenOperation:(PRTweenOperation*)operation
{
    if (timer == nil)
    {
        timer = [NSTimer scheduledTimerWithTimeInterval:kPRTweenFramerate target:self selector:@selector(update) userInfo:nil repeats:YES];
    }
...

And again at the bottom of the update method:

...
    if(tweenOperations.count == 0)
    {
        [timer invalidate];
        timer = nil;
    }
}

Let me know if I can pull this and add the code, I would be happy to!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant