moved drawFunc definition out of the shape initializers as a method to improve space performance

This commit is contained in:
Eric Rowell
2012-07-28 10:46:16 -07:00
parent a67c1e70b1
commit c4a359cd48
12 changed files with 670 additions and 698 deletions

View File

@@ -14,19 +14,7 @@ Kinetic.Sprite = Kinetic.Shape.extend({
frameRate: 17
});
config.drawFunc = function(context) {
if(!!this.attrs.image) {
var anim = this.attrs.animation;
var index = this.attrs.index;
var f = this.attrs.animations[anim][index];
context.beginPath();
context.rect(0, 0, f.width, f.height);
context.closePath();
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
}
};
config.drawFunc = this.drawFunc;
// call super constructor
this._super(config);
@@ -36,6 +24,19 @@ Kinetic.Sprite = Kinetic.Shape.extend({
that.setIndex(0);
});
},
drawFunc: function(context) {
if(this.attrs.image) {
var anim = this.attrs.animation;
var index = this.attrs.index;
var f = this.attrs.animations[anim][index];
context.beginPath();
context.rect(0, 0, f.width, f.height);
context.closePath();
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
}
},
/**
* start sprite animation
* @name start