mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-30 03:48:49 +00:00
Respect frameRate when scheduling timer in CPAnimation. Treat a frameRate of 0 as "really fast" instead of CPTimer default (10 fps).
This commit is contained in:
1 parent
b20d711922
commit
5cefce1cf0
2 files changed
+50
-1
No files matched your search
@@ -236,7 +236,9 @@ ACTUAL_FRAME_RATE = 0;
|
||||
ACTUAL_FRAME_RATE = 0;
|
||||
_lastTime = new Date();
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
var timerInterval = _frameRate <= 0.0 ? 0.0001 : 1.0/_frameRate;
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
@import <AppKit/CPApplication.j>
|
||||
@import <AppKit/CPAnimation.j>
|
||||
|
||||
[CPApplication sharedApplication];
|
||||
|
||||
@implementation CPAnimation (TestMethods)
|
||||
{
|
||||
}
|
||||
|
||||
- (CPTimer)timer
|
||||
{
|
||||
return _timer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPAnimationTest : OJTestCase
|
||||
{
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnDefaultFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:1.0/60.0 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnCustomFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation setFrameRate:30];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:1.0/30.0 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnAsFastAsPossibleFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation setFrameRate:0];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:0.0001 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user