From de1b53a04f1fef9f83812f1737cf6f54218f5577 Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Tue, 21 Nov 2017 14:38:08 +0800 Subject: [PATCH 1/3] fixed content size --- cocos2d/core/CCNode.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 67f5935e88..9df5b35157 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1541,21 +1541,21 @@ var Node = cc.Class({ var locContentSize = this._contentSize; var clone; if (height === undefined) { - if ((size.width === locContentSize.x) && (size.height === locContentSize.y)) + if ((size.width === locContentSize.width) && (size.height === locContentSize.height)) return; if (CC_EDITOR) { - clone = cc.size(locContentSize.x, locContentSize.y); + clone = cc.size(locContentSize.width, locContentSize.height); } - locContentSize.x = size.width; - locContentSize.y = size.height; + locContentSize.width = size.width; + locContentSize.height = size.height; } else { - if ((size === locContentSize.x) && (height === locContentSize.y)) + if ((size === locContentSize.width) && (height === locContentSize.height)) return; if (CC_EDITOR) { - clone = cc.size(locContentSize.x, locContentSize.y); + clone = cc.size(locContentSize.width, locContentSize.height); } - locContentSize.x = size; - locContentSize.y = height; + locContentSize.width = size; + locContentSize.height = height; } if (CC_EDITOR) { this.emit(SIZE_CHANGED, clone); @@ -1939,8 +1939,8 @@ var Node = cc.Class({ var contentSize = this._contentSize; // see getNodeToWorldTransform - var tx = this._anchorPoint.x * contentSize.x; - var ty = this._anchorPoint.y * contentSize.y; + var tx = this._anchorPoint.x * contentSize.width; + var ty = this._anchorPoint.y * contentSize.height; math.mat4.copy(_mat4_temp, this._worldMatrix); math.mat4.translate(_mat4_temp, tx, ty); From ef3c97cde2e44a8c4716d4f6a0b4861077e85208 Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Wed, 22 Nov 2017 14:09:21 +0800 Subject: [PATCH 2/3] init out if out is undefined --- cocos2d/core/CCNode.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 9df5b35157..b697540c2b 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1836,6 +1836,9 @@ var Node = cc.Class({ * node.getLocalMatrix(mat4); */ getLocalMatrix (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateLocalMatrix(); math.mat4.copy(out, this._matrix); }, @@ -1852,6 +1855,9 @@ var Node = cc.Class({ * node.getLocalMatrix(mat4); */ getWorldMatrix (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateWorldMatrix(); math.mat4.copy(out, this._worldMatrix); }, @@ -1869,6 +1875,9 @@ var Node = cc.Class({ * node.getNodeToParentTransform(affineTransform); */ getNodeToParentTransform (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateLocalMatrix(); return affineTrans.fromMatrix(this._matrix, out); }, @@ -1890,6 +1899,9 @@ var Node = cc.Class({ * node.getNodeToParentTransformAR(affineTransform); */ getNodeToParentTransformAR (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateLocalMatrix(); var contentSize = this._contentSize; @@ -1914,7 +1926,7 @@ var Node = cc.Class({ */ getNodeToWorldTransform (out) { if (!out) { - out = affineTrans.make(); + out = affineTrans.makeIdentity(); } this._updateWorldMatrix(); return affineTrans.fromMatrix(this._worldMatrix, out); @@ -1935,6 +1947,9 @@ var Node = cc.Class({ * node.getNodeToWorldTransformAR(affineTransform); */ getNodeToWorldTransformAR (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateWorldMatrix(); var contentSize = this._contentSize; @@ -1962,6 +1977,9 @@ var Node = cc.Class({ * node.getParentToNodeTransform(affineTransform); */ getParentToNodeTransform (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateLocalMatrix(); math.mat4.invert(_mat4_temp, this._matrix); return affineTrans.fromMatrix(_mat4_temp, out); @@ -1978,6 +1996,9 @@ var Node = cc.Class({ * node.getWorldToNodeTransform(affineTransform); */ getWorldToNodeTransform (out) { + if (!out) { + out = affineTrans.makeIdentity(); + } this._updateWorldMatrix(); math.mat4.invert(_mat4_temp, this._worldMatrix); return affineTrans.fromMatrix(_mat4_temp, out); From 69df47d3bf49fe2fa3afcf4713ff7281a3432567 Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Wed, 22 Nov 2017 15:20:46 +0800 Subject: [PATCH 3/3] reset getLocalMatrix getWorldMatrix --- cocos2d/core/CCNode.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index b697540c2b..2712af020f 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1836,9 +1836,6 @@ var Node = cc.Class({ * node.getLocalMatrix(mat4); */ getLocalMatrix (out) { - if (!out) { - out = affineTrans.makeIdentity(); - } this._updateLocalMatrix(); math.mat4.copy(out, this._matrix); }, @@ -1855,9 +1852,6 @@ var Node = cc.Class({ * node.getLocalMatrix(mat4); */ getWorldMatrix (out) { - if (!out) { - out = affineTrans.makeIdentity(); - } this._updateWorldMatrix(); math.mat4.copy(out, this._worldMatrix); },