Skip to content

Commit 24b223a

Browse files
committed
Added TimeScale component.
1 parent 20c230d commit 24b223a

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

v3/src/animation/frame/Animation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Animation.prototype = {
7777
{
7878
component.currentAnim = this;
7979

80-
component.timeScale = 1;
80+
component._timeScale = 1;
8181
component.frameRate = this.frameRate;
8282
component.duration = this.duration;
8383
component.msPerFrame = this.msPerFrame;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var TimeScale = function (value)
2+
{
3+
if (value === undefined)
4+
{
5+
return this._timeScale;
6+
}
7+
else
8+
{
9+
this._timeScale = value;
10+
11+
return this;
12+
}
13+
};
14+
15+
module.exports = TimeScale;

v3/src/animation/frame/Update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Update = function (timestamp)
55
return;
66
}
77

8-
this.accumulator += (timestamp - this.prevTick) * this.timeScale;
8+
this.accumulator += (timestamp - this.prevTick) * this._timeScale;
99

1010
this.prevTick = timestamp;
1111

v3/src/animation/frame/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
Restart: require('./Restart'),
1515
Resume: require('./Resume'),
1616
Stop: require('./Stop'),
17+
TimeScale: require('./TimeScale'),
1718
TotalFrames: require('./TotalFrames'),
1819
TotalProgress: require('./TotalProgress'),
1920
Update: require('./Update'),

v3/src/components/Animation.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ var Animation = new Class({
2727
// -------------------------
2828

2929
// Scale the time (make it go faster / slower)
30-
this.timeScale = 1;
30+
// Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc.
31+
this._timeScale = 1;
3132

3233
// The frame rate of playback in frames per second (default 24 if duration is null)
3334
this.frameRate = 0;
@@ -85,6 +86,7 @@ var Animation = new Class({
8586
restart: Components.Restart,
8687
resume: Components.Resume,
8788
stop: Components.Stop,
89+
timeScale: Components.TimeScale,
8890
totalFrames: Components.TotalFrames,
8991
totalProgress: Components.TotalProgress,
9092
update: Components.Update,

0 commit comments

Comments
 (0)