Merge branch 'master' of https://github.com/leohenning/KineticJS into leohenning-master

This commit is contained in:
lavrton
2015-01-21 17:12:07 +07:00

View File

@@ -87,6 +87,7 @@
index = this.frameIndex(),
ix4 = index * 4,
set = this.getAnimations()[anim],
offsets = this.getOffsets(),
x = set[ix4 + 0],
y = set[ix4 + 1],
width = set[ix4 + 2],
@@ -94,7 +95,13 @@
image = this.getImage();
if(image) {
context.drawImage(image, x, y, width, height, 0, 0, width, height);
if (offsets) {
var offset = offsets[anim],
ix2 = index * 2;
context.drawImage(image, x, y, width, height, offset[ix2 + 0], offset[ix2 + 1], width, height);
} else {
context.drawImage(image, x, y, width, height, 0, 0, width, height);
}
}
},
_hitFunc: function(context) {
@@ -226,6 +233,42 @@
* });
*/
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'offsets');
/**
* get/set offsets map
* @name offsets
* @method
* @memberof Kinetic.Sprite.prototype
* @param {Object} offsets
* @returns {Object}
* @example
* // get offsets map
* var offsets = sprite.offsets();
*
* // set offsets map
* sprite.offsets({
* standing: [
* // x, y (6 frames)
* 0, 0,
* 0, 0,
* 5, 0,
* 0, 0,
* 0, 3,
* 2, 0
* ],
* kicking: [
* // x, y (6 frames)
* 0, 5,
* 5, 0,
* 10, 0,
* 0, 0,
* 2, 1,
* 0, 0
* ]
* });
*/
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'image');
/**