greatly improved sprite animation performance by hooking into the global animation object

This commit is contained in:
Eric Rowell
2012-07-07 21:39:03 -07:00
parent a8ab9a2533
commit 30fd5c1fa7
6 changed files with 111 additions and 29 deletions

View File

@@ -26,12 +26,22 @@ Kinetic.Animation = {
},
_runFrames: function() {
var nodes = {};
/*
* loop through all animations and execute animation
* function. if the animation object has specified node,
* we can add the node to the nodes hash to eliminate
* drawing the same node multiple times. The node property
* can be the stage itself or a layer
*/
for(var n = 0; n < this.animations.length; n++) {
var anim = this.animations[n];
if(anim.node && anim.node._id !== undefined) {
nodes[anim.node._id] = anim.node;
}
anim.func(this.frame);
// if animation object has a function, execute it
if(anim.func) {
anim.func(this.frame);
}
}
for(var key in nodes) {