animation system update
parent
74ef87c6aa
commit
85b65a2672
|
@ -371,6 +371,23 @@ GameLib.Event.Emit = function(
|
|||
var count = 0;
|
||||
|
||||
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(
|
||||
function(callback) {
|
||||
if (callback) {
|
||||
|
|
|
@ -19,23 +19,47 @@ GameLib.System.Animation.prototype.start = function() {
|
|||
|
||||
GameLib.System.prototype.start.call(this);
|
||||
|
||||
this.renderSubscriptions = [];
|
||||
|
||||
this.animateSubscription = GameLib.Event.Subscribe(
|
||||
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(
|
||||
|
||||
this.renderSubscription = GameLib.Event.Subscribe(
|
||||
GameLib.Event.BEFORE_RENDER,
|
||||
function(data) {
|
||||
if (clientCallback(data)) {
|
||||
this.renderSubscription.remove();
|
||||
|
||||
function(subscriptionIndex) {
|
||||
return function(renderData) {
|
||||
|
||||
if (
|
||||
clientCallback(
|
||||
{
|
||||
renderData : renderData,
|
||||
animationData : animationData
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
) {
|
||||
|
||||
this.renderSubscriptions[subscriptionIndex].remove();
|
||||
|
||||
animationData.done();
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
|
||||
}.bind(this)(this.renderSubscriptions.length)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue