forked from Wizcorp/tina.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweener.js
48 lines (40 loc) · 1.32 KB
/
Tweener.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var Player = require('./Player');
var TINA = require('./TINA');
/**
* @classdesc
* Manages the update of a list of playable with respect to a given elapsed time.
*/
function Tweener() {
Player.call(this);
// TINA is the player for all the tweeners
this._player = TINA;
}
Tweener.prototype = Object.create(Player.prototype);
Tweener.prototype.constructor = Tweener;
module.exports = Tweener;
Tweener.prototype._reactivate = function (playable) {
if (playable._handle === null) {
// In a tweener, playables are added when reactivated
this._add(playable);
}
Player.prototype._activate.call(this, playable);
};
Tweener.prototype._inactivate = function (playable) {
// In a tweener, playables are removed when inactivated
if (playable._handle !== null) {
// Playable is handled, either by this player or by another one
if (playable._handle.container === this._activePlayables) {
// and adding to remove list
playable._handle = this._playablesToRemove.add(playable._handle);
}
if (playable._handle.container === this._inactivePlayables) {
// Playable was inactive, removing from inactive playables
playable._handle = this._inactivePlayables.removeByReference(playable._handle);
}
}
playable._active = false;
};
Tweener.prototype.useAsDefault = function () {
TINA.setDefaultTweener(this);
return this;
};