Skip to content

Commit b769fe3

Browse files
committed
Create base TweenManager and added to State Systems.
1 parent 5950bc8 commit b769fe3

4 files changed

Lines changed: 106 additions & 0 deletions

File tree

v3/src/state/Systems.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var Settings = require('./Settings');
99
var StableSort = require('../utils/array/StableSort');
1010
var StateManager = require('./systems/StateManager');
1111
var UpdateManager = require('./systems/UpdateManager');
12+
var TweenManager = require('../tween/TweenManager');
1213

1314
var Systems = function (state, config)
1415
{
@@ -46,6 +47,7 @@ var Systems = function (state, config)
4647
this.make;
4748
this.stateManager;
4849
this.updates;
50+
this.tweens;
4951

5052
// State properties
5153
this.children;
@@ -85,6 +87,7 @@ Systems.prototype = {
8587
this.load = new Loader(this.state);
8688
this.make = new GameObjectCreator(this.state);
8789
this.stateManager = new StateManager(this.state, game);
90+
this.tweens = new TweenManager(this.state);
8891
this.updates = new UpdateManager(this.state);
8992

9093
this.inject();
@@ -108,6 +111,7 @@ Systems.prototype = {
108111
this.state.load = this.load;
109112
this.state.settings = this.settings;
110113
this.state.state = this.stateManager;
114+
this.state.tweens = this.tweens;
111115

112116
this.state.children = this.children;
113117
this.state.color = this.color;
@@ -116,6 +120,9 @@ Systems.prototype = {
116120

117121
step: function (time, delta)
118122
{
123+
// Before or after child update?
124+
this.tweens.update(time, delta);
125+
119126
var list = this.children.list;
120127

121128
for (var i = 0; i < list.length; i++)

v3/src/tween/Tween.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var Tween = function (manager)
2+
{
3+
this.manager = manager;
4+
};
5+
6+
Tween.prototype.constructor = Tween;
7+
8+
Tween.prototype = {
9+
};
10+
11+
module.exports = Tween;

v3/src/tween/TweenData.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var TweenData = function (parent)
2+
{
3+
this.tween = parent;
4+
};
5+
6+
TweenData.prototype.constructor = TweenData;
7+
8+
TweenData.prototype = {
9+
};
10+
11+
module.exports = TweenData;

v3/src/tween/TweenManager.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
var GetValue = require('../utils/object/GetValue');
3+
var EventDispatcher = require('../events/EventDispatcher');
4+
var Tween = require('./Tween');
5+
6+
var TweenManager = function (state)
7+
{
8+
// The State the Tween Manager belongs to (tweens are State specific, not Game global)
9+
this.state = state;
10+
11+
/**
12+
* @property {EventDispatcher} events - Global / Global Game System Events
13+
*/
14+
this.events = new EventDispatcher(); // should use State event dispatcher?
15+
16+
this.list = [];
17+
};
18+
19+
TweenManager.prototype.constructor = TweenManager;
20+
21+
TweenManager.prototype = {
22+
23+
boot: function ()
24+
{
25+
// State is starting up
26+
},
27+
28+
add: function (config)
29+
{
30+
},
31+
32+
exists: function (tween)
33+
{
34+
},
35+
36+
get: function (target)
37+
{
38+
},
39+
40+
update: function (timestamp, delta)
41+
{
42+
43+
},
44+
45+
/**
46+
* Passes all Tweens to the given callback.
47+
*
48+
* @method each
49+
* @param {function} callback - The function to call.
50+
* @param {object} [thisArg] - Value to use as `this` when executing callback.
51+
* @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child.
52+
*/
53+
each: function (callback, thisArg)
54+
{
55+
var args = [ null ];
56+
57+
for (var i = 1; i < arguments.length; i++)
58+
{
59+
args.push(arguments[i]);
60+
}
61+
62+
for (var texture in this.list)
63+
{
64+
args[0] = this.list[texture];
65+
66+
callback.apply(thisArg, args);
67+
}
68+
},
69+
70+
shutdown: function ()
71+
{
72+
// State is shutting down (swapping to another State)
73+
}
74+
75+
};
76+
77+
module.exports = TweenManager;

0 commit comments

Comments
 (0)