2017-09-05 05:22:52 +02:00
|
|
|
/**
|
|
|
|
* System takes care of updating all the entities (based on their component data)
|
|
|
|
* @param apiSystem GameLib.API.System
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.System.Animation = function(
|
|
|
|
apiSystem
|
|
|
|
) {
|
|
|
|
GameLib.System.call(
|
|
|
|
this,
|
|
|
|
apiSystem
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.System.Animation.prototype = Object.create(GameLib.System.prototype);
|
|
|
|
GameLib.System.Animation.prototype.constructor = GameLib.System.Animation;
|
|
|
|
|
|
|
|
GameLib.System.Animation.prototype.start = function() {
|
2017-09-14 05:42:38 +02:00
|
|
|
|
|
|
|
GameLib.System.prototype.start.call(this);
|
|
|
|
|
2017-09-14 10:50:09 +02:00
|
|
|
this.renderSubscriptions = [];
|
|
|
|
|
2017-09-14 05:42:38 +02:00
|
|
|
this.animateSubscription = GameLib.Event.Subscribe(
|
|
|
|
GameLib.Event.ANIMATE,
|
2017-09-14 10:50:09 +02:00
|
|
|
this.animate.bind(this)
|
2017-09-14 05:42:38 +02:00
|
|
|
);
|
|
|
|
|
2017-09-14 10:50:09 +02:00
|
|
|
|
2017-09-05 05:22:52 +02:00
|
|
|
};
|
|
|
|
|
2017-09-14 10:50:09 +02:00
|
|
|
GameLib.System.Animation.prototype.animate = function(animationData, clientCallback) {
|
|
|
|
|
|
|
|
this.renderSubscriptions.push(
|
|
|
|
|
|
|
|
new GameLib.Event.Subscribe(
|
|
|
|
|
|
|
|
GameLib.Event.BEFORE_RENDER,
|
|
|
|
|
|
|
|
function(subscriptionIndex) {
|
|
|
|
return function(renderData) {
|
|
|
|
|
|
|
|
if (
|
|
|
|
clientCallback(
|
|
|
|
{
|
|
|
|
renderData : renderData,
|
|
|
|
animationData : animationData
|
|
|
|
}
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
|
|
|
|
this.renderSubscriptions[subscriptionIndex].remove();
|
|
|
|
|
|
|
|
animationData.done();
|
|
|
|
}
|
|
|
|
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
}.bind(this)(this.renderSubscriptions.length)
|
|
|
|
)
|
|
|
|
);
|
2017-09-14 05:42:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
};
|
2017-09-05 05:22:52 +02:00
|
|
|
|
|
|
|
GameLib.System.Animation.prototype.stop = function() {
|
2017-09-14 05:42:38 +02:00
|
|
|
|
|
|
|
GameLib.System.prototype.stop.call(this);
|
|
|
|
|
|
|
|
this.animateSubscription.remove();
|
2017-09-05 05:22:52 +02:00
|
|
|
};
|
|
|
|
|