fix #149 began decoupling scene graph draw and buffer graph draw logic. This will enable more flexibility for developers to define custom buffer draw functions, and it also improves draw performance for both the scene and buffer graphs, because each function can be optimized for its purpose. Also moved text drawing logic to the Text shape

This commit is contained in:
Eric Rowell
2012-11-12 19:59:19 -08:00
parent a30d6730fe
commit 5be1802729
10 changed files with 187 additions and 125 deletions

View File

@@ -19,6 +19,7 @@ Kinetic.Sprite.prototype = {
});
this.shapeType = "Sprite";
config.drawFunc = this.drawFunc;
config.drawBufferFunc = this.drawBufferFunc;
// call super constructor
Kinetic.Shape.call(this, config);
this.anim = new Kinetic.Animation();
@@ -48,6 +49,17 @@ Kinetic.Sprite.prototype = {
this.drawImage(context, this.attrs.image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
}
},
drawBufferFunc: function(context) {
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.fill(context);
this.stroke(context);
},
/**
* start sprite animation
* @name start