Skip to content

Frame rate is not consistent if runloop falls below 60 fps #36

Description

@jowie

If the app is running at less than 60 fps, the NSTimer is not called quickly enough and the tween runs too slowly.

I have made another fix to my local copy, whereby each frame it calculates timeOffset based upon CFAbsoluteTimeGetCurrent(), adding a new ivar lastAbsoluteTime:

- (void)update
{
    timeOffset += (lastAbsoluteTime == 0) ? kPRTweenFramerate : (CFAbsoluteTimeGetCurrent() - lastAbsoluteTime);
    lastAbsoluteTime = CFAbsoluteTimeGetCurrent();
    ...

Also resetting lastAbsoluteTime when the NSTimer is reinitialised (as per my other issue):

    if (timer == nil)
    {
        lastAbsoluteTime = 0;
        timer = [NSTimer scheduledTimerWithTimeInterval:kPRTweenFramerate target:self selector:@selector(update) userInfo:nil repeats:YES];
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions