Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions extensions/cocostudio/armature/CCArmature.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
****************************************************************************/

/**
* Base class for ccs.Armature objects.
* The main class of Armature, it plays armature animation, manages and updates bones' state.
* @class
* @extends ccs.Node
*
Expand Down Expand Up @@ -70,7 +70,6 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
this._offsetPoint = cc.p(0, 0);
this._armatureTransformDirty = true;
this._realAnchorPointInPoints = cc.p(0, 0);

name && ccs.Armature.prototype.init.call(this, name, parentBone);
},

Expand Down Expand Up @@ -277,6 +276,12 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
this.setAnchorPoint(locOffsetPoint.x / rect.width, locOffsetPoint.y / rect.height);
},

/**
* Sets armature's anchor point, because it need to consider offset point, so here is the override function.
* @override
* @param {cc.Point|Number} point point or x of point
* @param {Number} [y] y of point
*/
setAnchorPoint: function(point, y){
var ax, ay;
if(y !== undefined){
Expand Down Expand Up @@ -316,6 +321,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
this.setNodeDirty();
},

/**
* Returns the anchor point in points of ccs.Armature.
* @override
* @returns {cc.Point}
*/
getAnchorPointInPoints: function(){
return this._realAnchorPointInPoints;
},
Expand Down Expand Up @@ -344,6 +354,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
return this._armatureTransformDirty;
},

/**
* The update callback of ccs.Armature, it updates animation's state and updates bone's state.
* @override
* @param {Number} dt
*/
update: function (dt) {
this.animation.update(dt);
var locTopBoneList = this._topBoneList;
Expand All @@ -352,6 +367,11 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
this._armatureTransformDirty = false;
},

/**
* Draws armature's display render node.
* @override
* @param {CanvasRenderingContext2D | WebGLRenderingContext} ctx The render context
*/
draw: function(ctx){
if (this._parentBone == null && this._batchNode == null) {
// CC_NODE_DRAW_SETUP();
Expand Down Expand Up @@ -408,11 +428,19 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
}
},

/**
* The callback when ccs.Armature enter stage.
* @override
*/
onEnter: function () {
cc.Node.prototype.onEnter.call(this);
this.scheduleUpdate();
},

/**
* The callback when ccs.Armature exit stage.
* @override
*/
onExit: function () {
cc.Node.prototype.onExit.call(this);
this.unscheduleUpdate();
Expand Down Expand Up @@ -531,7 +559,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
},

/**
* return parent bone
* Return parent bone of ccs.Armature.
* @returns {ccs.Bone}
*/
getParentBone: function () {
Expand Down Expand Up @@ -559,6 +587,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
}
},


setBody: function (body) {
if (this._body == body)
return;
Expand Down Expand Up @@ -591,15 +620,15 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
},

/**
* conforms to cc.TextureProtocol protocol
* Sets the blendFunc to ccs.Armature
* @param {cc.BlendFunc} blendFunc
*/
setBlendFunc: function (blendFunc) {
this._blendFunc = blendFunc;
},

/**
* blendFunc getter
* Returns the blendFunc of ccs.Armature
* @returns {cc.BlendFunc}
*/
getBlendFunc: function () {
Expand All @@ -617,7 +646,7 @@ ccs.Armature = ccs.Node.extend(/** @lends ccs.Armature# */{
},

/**
* Gets the armatureData of this Armature
* Returns the armatureData of ccs.Armature
* @return {ccs.ArmatureData}
*/
getArmatureData: function () {
Expand Down
Loading