animation system update
parent
74ef87c6aa
commit
85b65a2672
|
@ -371,6 +371,23 @@ GameLib.Event.Emit = function(
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
if (GameLib.Event.Subscriptions.hasOwnProperty(eventName)) {
|
||||||
|
|
||||||
|
if (GameLib.Event.Subscriptions[eventName].length === 0) {
|
||||||
|
|
||||||
|
if (clientCallback) {
|
||||||
|
/**
|
||||||
|
* We execute the client callback immediately since there are no subscriptions to this event
|
||||||
|
*/
|
||||||
|
clientCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientErrorCallback) {
|
||||||
|
clientErrorCallback({
|
||||||
|
message : 'No subscriptions for event ' + eventName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.Event.Subscriptions[eventName].map(
|
GameLib.Event.Subscriptions[eventName].map(
|
||||||
function(callback) {
|
function(callback) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
|
|
|
@ -19,23 +19,47 @@ GameLib.System.Animation.prototype.start = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.start.call(this);
|
GameLib.System.prototype.start.call(this);
|
||||||
|
|
||||||
|
this.renderSubscriptions = [];
|
||||||
|
|
||||||
this.animateSubscription = GameLib.Event.Subscribe(
|
this.animateSubscription = GameLib.Event.Subscribe(
|
||||||
GameLib.Event.ANIMATE,
|
GameLib.Event.ANIMATE,
|
||||||
this.animate
|
this.animate.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Animation.prototype.animate = function(data, clientCallback) {
|
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)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
this.renderSubscription = GameLib.Event.Subscribe(
|
|
||||||
GameLib.Event.BEFORE_RENDER,
|
|
||||||
function(data) {
|
|
||||||
if (clientCallback(data)) {
|
|
||||||
this.renderSubscription.remove();
|
|
||||||
}
|
|
||||||
}.bind(this)
|
|
||||||
)
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue