From 68affd39da0413a4cbb3cbb7f6d036102231309d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 7 Dec 2015 14:47:22 +0800 Subject: [PATCH 1/9] raw version for mask --- cocos2d/core/components/CCMask.js | 128 ++++++++++++++++++++++++++++++ cocos2d/core/components/index.js | 3 +- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 cocos2d/core/components/CCMask.js diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js new file mode 100644 index 0000000000..8463f066e6 --- /dev/null +++ b/cocos2d/core/components/CCMask.js @@ -0,0 +1,128 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +function MonitorSize(target) { + this._target = target; +} +MonitorSize.prototype = { + getContentSize: function () { + return this._target._sgNode.getContentSize(); + }, + setContentSize: function (size) { + this._target._useOriginalSize = false; + this._target._sgNode.setContentSize(size); + }, + _getWidth: function () { + return this.getContentSize().width; + }, + _getHeight: function () { + return this.getContentSize().height; + } +}; +var HorizontalAlign = cc.TextAlignment; +var VerticalAlign = cc.VerticalTextAlignment; +var Overflow = cc.Label.Overflow; +var LabelType = cc.Label.Type; +/** + * + * @class ELabel + * @extends _ComponentInSG + */ +var Mask = cc.Class({ + name: 'cc.Mask', + extends: cc._ComponentInSG, + + editor: CC_EDITOR && { + menu: 'UI/Mask' + }, + + properties: { + _useOriginalSize: true, + + // _aheheValue: 30, + // ahehe: { + // get: function() { + // return this._aheheValue; + // }, + // set: function(value) { + // this._aheheValue = value; + // }, + // }, + + // _fontSize: 40, + // /** + // * Font size of label + // * @property {Number} fontSize + // */ + // fontSize: { + // get: function(){ + // var sgNode = this._sgNode; + // if(sgNode){ + // this._fontSize = sgNode.getFontSize(); + // } + // return this._fontSize; + // }, + // set: function(value){ + // this._fontSize = value; + + // var sgNode = this._sgNode; + // if(sgNode){ + // sgNode.setFontSize(value); + // } + // } + // }, + + + }, + + onLoad: function () { + this._super(); + this.node._sizeProvider = new MonitorSize(this); + }, + + onDestroy: function () { + this._super(); + this.node._sizeProvider = null; + }, + _createSgNode: function () { + var sgNode = new cc.Label(this.string, this.file, cc.Label.Type.TTF); + + // TODO + // sgNode.enableRichText = this.enableRichText; + + sgNode.setHorizontalAlign( this.horizontalAlign ); + sgNode.setVerticalAlign( this.verticalAlign ); + sgNode.setFontSize( this.fontSize ); + sgNode.setOverflow( this.overflow ); + sgNode.enableWrapText( this.enableWrapText ); + if(!this._useOriginalSize){ + sgNode.setContentSize(this.node.getContentSize()); + } + sgNode.setColor(this.node.color); + + return sgNode; + } + }); + + cc.Mask = module.exports = Mask; diff --git a/cocos2d/core/components/index.js b/cocos2d/core/components/index.js index 4e6e53e7fb..2479429796 100644 --- a/cocos2d/core/components/index.js +++ b/cocos2d/core/components/index.js @@ -8,5 +8,6 @@ module.exports = [ require('./CCAudioSource'), require('./CCAnimation'), require('./CCButton'), - require('./CCELabel') + require('./CCELabel'), + require('./CCMask') ]; From e522073ef2846bff3ae6a185627ac08ae8f4336d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 8 Dec 2015 11:28:02 +0800 Subject: [PATCH 2/9] raw version mask works --- cocos2d/core/components/CCMask.js | 79 ++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 8463f066e6..9db4edf179 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -57,8 +57,10 @@ var Mask = cc.Class({ menu: 'UI/Mask' }, + _clippingNode: null, + _clippingStencil: null, + _sizeProvider: null, properties: { - _useOriginalSize: true, // _aheheValue: 30, // ahehe: { @@ -97,32 +99,75 @@ var Mask = cc.Class({ }, onLoad: function () { + // var sgNode = this._createSgNode(); + // this._appendSgNode(sgNode); + // if ( !this.node._sizeProvider ) { + // this.node._sizeProvider = sgNode; + // } this._super(); - this.node._sizeProvider = new MonitorSize(this); + this._clippingNode = new cc.ClippingNode(this._sgNode); + //this._sizeProvider = new MonitorSize(this); }, + onEnable: function () { + // if (this._sgNode) { + // this._sgNode.visible = true; + // } + this._super(); + //this.node._sizeProvider = this._sizeProvider; + var oldNode = this.node._sgNode; + this.node._sgNode = this._clippingNode; + this._rebuildSceneGraph(this._clippingNode,oldNode); + //this.node._sizeProvider = this._sizeProvider; + //this.node.width = this.node.height = 100; + }, + onDisable: function () { + // if (this._sgNode) { + // this._sgNode.visible = false; + // } + this._super(); + //this.node._sizeProvider = null; + var oldNode = this.node._sgNode; + this.node._sgNode = new cc.Node(); + this._rebuildSceneGraph(this.node._sgNode, oldNode); + + }, + onDestroy: function () { this._super(); - this.node._sizeProvider = null; + //this._sizeProvider = null; }, + _createSgNode: function () { - var sgNode = new cc.Label(this.string, this.file, cc.Label.Type.TTF); + return new cc.LayerColor(new cc.Color(255,255,255,255),100,100); + }, + + _rebuildSceneGraph: function (newNode, oldNode) { - // TODO - // sgNode.enableRichText = this.enableRichText; - - sgNode.setHorizontalAlign( this.horizontalAlign ); - sgNode.setVerticalAlign( this.verticalAlign ); - sgNode.setFontSize( this.fontSize ); - sgNode.setOverflow( this.overflow ); - sgNode.enableWrapText( this.enableWrapText ); - if(!this._useOriginalSize){ - sgNode.setContentSize(this.node.getContentSize()); + var children = []; + children = children.concat(oldNode.getChildren()); + + for(var index = 0; index < children.length; ++index) { + children[index].removeFromParent(); + newNode.addChild(children[index]); } - sgNode.setColor(this.node.color); + var parentNode = oldNode.getParent(); + oldNode.removeFromParent(); + parentNode.addChild(newNode); + + this.node.position = this.node._position; + this.node.rotationX = this.node._rotationX; + this.node.rotationY = this.node._rotationY; + this.node.scaleX = this.node._scaleX; + this.node.scaleY = this.node._scaleY; + this.node.anchorX = this.node._anchorPoint.x; + this.node.anchorY = this.node._anchorPoint.y; + this.node.width = this.node._contentSize.width; + this.node.height = this.node._contentSize.height; + this.node.opacity = this.node._opacity; + this.node.color = this.node._color; + }, - return sgNode; - } }); cc.Mask = module.exports = Mask; From 36660c6864b9d753116147a04caaa650c5811080 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 8 Dec 2015 14:59:56 +0800 Subject: [PATCH 3/9] fix mask content size bug --- cocos2d/core/components/CCMask.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 9db4edf179..02eb46a2c4 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -106,16 +106,17 @@ var Mask = cc.Class({ // } this._super(); this._clippingNode = new cc.ClippingNode(this._sgNode); - //this._sizeProvider = new MonitorSize(this); + this._sizeProvider = new MonitorSize(this); }, onEnable: function () { // if (this._sgNode) { // this._sgNode.visible = true; // } this._super(); - //this.node._sizeProvider = this._sizeProvider; + this.node._sizeProvider = this._sizeProvider; var oldNode = this.node._sgNode; this.node._sgNode = this._clippingNode; + this.node._sgNode.setContentSize(this.node._contentSize); this._rebuildSceneGraph(this._clippingNode,oldNode); //this.node._sizeProvider = this._sizeProvider; //this.node.width = this.node.height = 100; @@ -126,16 +127,17 @@ var Mask = cc.Class({ // this._sgNode.visible = false; // } this._super(); - //this.node._sizeProvider = null; + this.node._sizeProvider = null; var oldNode = this.node._sgNode; this.node._sgNode = new cc.Node(); + this.node._sgNode.setContentSize(this.node._contentSize); this._rebuildSceneGraph(this.node._sgNode, oldNode); }, onDestroy: function () { this._super(); - //this._sizeProvider = null; + this._sizeProvider = null; }, _createSgNode: function () { From 8a89395fc55bdb9c75c60fff668232f52547112f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 11:54:00 +0800 Subject: [PATCH 4/9] mask works with bug --- cocos2d/core/components/CCMask.js | 165 ++++++++++-------------------- 1 file changed, 56 insertions(+), 109 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 02eb46a2c4..5e8437ab24 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -22,152 +22,99 @@ THE SOFTWARE. ****************************************************************************/ -function MonitorSize(target) { - this._target = target; -} -MonitorSize.prototype = { - getContentSize: function () { - return this._target._sgNode.getContentSize(); - }, - setContentSize: function (size) { - this._target._useOriginalSize = false; - this._target._sgNode.setContentSize(size); - }, - _getWidth: function () { - return this.getContentSize().width; - }, - _getHeight: function () { - return this.getContentSize().height; - } -}; -var HorizontalAlign = cc.TextAlignment; -var VerticalAlign = cc.VerticalTextAlignment; -var Overflow = cc.Label.Overflow; -var LabelType = cc.Label.Type; /** * - * @class ELabel - * @extends _ComponentInSG + * @class Mask + * @extends Component */ var Mask = cc.Class({ name: 'cc.Mask', - extends: cc._ComponentInSG, + extends: cc.Component, editor: CC_EDITOR && { - menu: 'UI/Mask' + menu: 'UI/Mask', + executeInEditMode: true }, _clippingNode: null, _clippingStencil: null, - _sizeProvider: null, - properties: { + // properties: { - // _aheheValue: 30, - // ahehe: { - // get: function() { - // return this._aheheValue; - // }, - // set: function(value) { - // this._aheheValue = value; - // }, - // }, - - // _fontSize: 40, - // /** - // * Font size of label - // * @property {Number} fontSize - // */ - // fontSize: { - // get: function(){ - // var sgNode = this._sgNode; - // if(sgNode){ - // this._fontSize = sgNode.getFontSize(); - // } - // return this._fontSize; - // }, - // set: function(value){ - // this._fontSize = value; - - // var sgNode = this._sgNode; - // if(sgNode){ - // sgNode.setFontSize(value); - // } - // } - // }, - - - }, + // }, onLoad: function () { - // var sgNode = this._createSgNode(); - // this._appendSgNode(sgNode); - // if ( !this.node._sizeProvider ) { - // this.node._sizeProvider = sgNode; - // } - this._super(); - this._clippingNode = new cc.ClippingNode(this._sgNode); - this._sizeProvider = new MonitorSize(this); + this._clippingStencil = new cc.LayerColor(cc.Color.WHITE, 200,200); + this._clippingStencil.ignoreAnchorPointForPosition(false); + this._clippingNode = new cc.ClippingNode(this._clippingStencil); + this.node.on('size-changed',this._onContentResize, this); }, + onEnable: function () { - // if (this._sgNode) { - // this._sgNode.visible = true; - // } - this._super(); - this.node._sizeProvider = this._sizeProvider; var oldNode = this.node._sgNode; - this.node._sgNode = this._clippingNode; - this.node._sgNode.setContentSize(this.node._contentSize); + this._clippingStencil.setContentSize(this.node._contentSize); + this._clippingStencil.setAnchorPoint(this.node._anchorPoint); this._rebuildSceneGraph(this._clippingNode,oldNode); - //this.node._sizeProvider = this._sizeProvider; - //this.node.width = this.node.height = 100; - + this.node._sgNode = this._clippingNode; }, - onDisable: function () { - // if (this._sgNode) { - // this._sgNode.visible = false; - // } - this._super(); - this.node._sizeProvider = null; - var oldNode = this.node._sgNode; - this.node._sgNode = new cc.Node(); - this.node._sgNode.setContentSize(this.node._contentSize); - this._rebuildSceneGraph(this.node._sgNode, oldNode); + onDisable: function () { + var oldNode = this.node._sgNode; + var newNode = new _ccsg.Node(); + //this.node._sgNode.setContentSize(this.node._contentSize); + this._rebuildSceneGraph(newNode, oldNode); + this.node._sgNode = newNode; }, onDestroy: function () { - this._super(); - this._sizeProvider = null; + // this.node._sgNode.removeChild(this._clippingStencil); + this.node.off('size-changed', this._onContentResize, this); }, - _createSgNode: function () { - return new cc.LayerColor(new cc.Color(255,255,255,255),100,100); + _onContentResize: function() { + if(this._clippingNode) { + this._clippingNode.setContentSize(this.node._contentSize); + } + if(this._clippingStencil) { + this._clippingStencil.setContentSize(this.node._contentSize); + this._clippingStencil.setAnchorPoint(this.node._anchorPoint); + } }, - + _rebuildSceneGraph: function (newNode, oldNode) { + newNode.setPosition(this.node._position); + newNode.setRotationX(this.node._rotationX); + newNode.setRotationY(this.node._rotationY); + newNode.setScaleX(this.node._scaleX); + newNode.setScaleY(this.node._scaleY); + newNode.setAnchorPoint(this.node._anchorPoint); + newNode.setContentSize(this.node._contentSize); + newNode.setOpacity(this.node._opacity); + newNode.setColor(this.node._color); + var children = []; children = children.concat(oldNode.getChildren()); for(var index = 0; index < children.length; ++index) { - children[index].removeFromParent(); + oldNode.removeChild(children[index]) newNode.addChild(children[index]); } + var parentNode = oldNode.getParent(); - oldNode.removeFromParent(); parentNode.addChild(newNode); + parentNode.removeChild(oldNode); - this.node.position = this.node._position; - this.node.rotationX = this.node._rotationX; - this.node.rotationY = this.node._rotationY; - this.node.scaleX = this.node._scaleX; - this.node.scaleY = this.node._scaleY; - this.node.anchorX = this.node._anchorPoint.x; - this.node.anchorY = this.node._anchorPoint.y; - this.node.width = this.node._contentSize.width; - this.node.height = this.node._contentSize.height; - this.node.opacity = this.node._opacity; - this.node.color = this.node._color; + // this.node.position = ; + // this.node.rotationX = this.node._rotationX; + // this.node.rotationY = this.node._rotationY; + // this.node.scaleX = ; + // this.node.scaleY = this.node._scaleY; + // this.node.anchorX = this.node._anchorPoint.x; + // this.node.anchorY = this.node._anchorPoint.y; + // this.node.width = this.node._contentSize.width; + // this.node.height = this.node._contentSize.height; + // this.node.opacity = this.node._opacity; + // this.node.color = this.node._color; }, }); From 7a4e7b3ba12375a905aab2bcb76ab5c8b8b734e7 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 13:54:33 +0800 Subject: [PATCH 5/9] mask works, anchor point not work --- cocos2d/core/components/CCMask.js | 27 +++++---------------------- cocos2d/core/components/index.js | 2 +- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 5e8437ab24..d0ea1d6933 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -46,7 +46,6 @@ var Mask = cc.Class({ this._clippingStencil = new cc.LayerColor(cc.Color.WHITE, 200,200); this._clippingStencil.ignoreAnchorPointForPosition(false); this._clippingNode = new cc.ClippingNode(this._clippingStencil); - this.node.on('size-changed',this._onContentResize, this); }, onEnable: function () { @@ -55,25 +54,22 @@ var Mask = cc.Class({ this._clippingStencil.setAnchorPoint(this.node._anchorPoint); this._rebuildSceneGraph(this._clippingNode,oldNode); this.node._sgNode = this._clippingNode; + this.node.on('size-changed',this._onContentResize, this); }, onDisable: function () { var oldNode = this.node._sgNode; var newNode = new _ccsg.Node(); - //this.node._sgNode.setContentSize(this.node._contentSize); this._rebuildSceneGraph(newNode, oldNode); this.node._sgNode = newNode; - }, - - onDestroy: function () { - // this.node._sgNode.removeChild(this._clippingStencil); this.node.off('size-changed', this._onContentResize, this); }, + onDestroy: function () { + + }, + _onContentResize: function() { - if(this._clippingNode) { - this._clippingNode.setContentSize(this.node._contentSize); - } if(this._clippingStencil) { this._clippingStencil.setContentSize(this.node._contentSize); this._clippingStencil.setAnchorPoint(this.node._anchorPoint); @@ -87,8 +83,6 @@ var Mask = cc.Class({ newNode.setRotationY(this.node._rotationY); newNode.setScaleX(this.node._scaleX); newNode.setScaleY(this.node._scaleY); - newNode.setAnchorPoint(this.node._anchorPoint); - newNode.setContentSize(this.node._contentSize); newNode.setOpacity(this.node._opacity); newNode.setColor(this.node._color); @@ -104,17 +98,6 @@ var Mask = cc.Class({ parentNode.addChild(newNode); parentNode.removeChild(oldNode); - // this.node.position = ; - // this.node.rotationX = this.node._rotationX; - // this.node.rotationY = this.node._rotationY; - // this.node.scaleX = ; - // this.node.scaleY = this.node._scaleY; - // this.node.anchorX = this.node._anchorPoint.x; - // this.node.anchorY = this.node._anchorPoint.y; - // this.node.width = this.node._contentSize.width; - // this.node.height = this.node._contentSize.height; - // this.node.opacity = this.node._opacity; - // this.node.color = this.node._color; }, }); diff --git a/cocos2d/core/components/index.js b/cocos2d/core/components/index.js index b054b0b56a..0bc0e824d5 100644 --- a/cocos2d/core/components/index.js +++ b/cocos2d/core/components/index.js @@ -9,6 +9,6 @@ module.exports = [ require('./CCAnimation'), require('./CCButton'), require('./CCELabel'), - require('./CCMask') + require('./CCMask'), require('./CCProgressBar') ]; From 5f92e37c0dc83c4c6ddf14f3b8b499ad51c4bc69 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 14:25:30 +0800 Subject: [PATCH 6/9] refine code --- cocos2d/core/components/CCMask.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index d0ea1d6933..39add6817a 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -86,11 +86,9 @@ var Mask = cc.Class({ newNode.setOpacity(this.node._opacity); newNode.setColor(this.node._color); - var children = []; - children = children.concat(oldNode.getChildren()); - + var children = oldNode.getChildren().slice(0); + oldNode.removeAllChildren(); for(var index = 0; index < children.length; ++index) { - oldNode.removeChild(children[index]) newNode.addChild(children[index]); } From f5a71d5e0fdc7d749c7604cd9c6b64b031b77c80 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 14:58:08 +0800 Subject: [PATCH 7/9] refine code --- cocos2d/core/components/CCMask.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 39add6817a..9b928dcee1 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -36,11 +36,16 @@ var Mask = cc.Class({ executeInEditMode: true }, - _clippingNode: null, - _clippingStencil: null, - // properties: { - - // }, + properties: { + _clippingNode: { + default: null, + serializable: false, + }, + _clippingStencil: { + default: null, + serializable: false, + }, + }, onLoad: function () { this._clippingStencil = new cc.LayerColor(cc.Color.WHITE, 200,200); @@ -81,8 +86,7 @@ var Mask = cc.Class({ newNode.setPosition(this.node._position); newNode.setRotationX(this.node._rotationX); newNode.setRotationY(this.node._rotationY); - newNode.setScaleX(this.node._scaleX); - newNode.setScaleY(this.node._scaleY); + newNode.setScale(this.node._scaleX, this.node._scaleY); newNode.setOpacity(this.node._opacity); newNode.setColor(this.node._color); From a190393dd48cc3af5a73eecc09ef1c3bd3a266a5 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 17:25:01 +0800 Subject: [PATCH 8/9] fix bug when stencil's content size is changed --- cocos2d/core/components/CCMask.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 9b928dcee1..2b4fad4259 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -78,9 +78,16 @@ var Mask = cc.Class({ if(this._clippingStencil) { this._clippingStencil.setContentSize(this.node._contentSize); this._clippingStencil.setAnchorPoint(this.node._anchorPoint); + this._dirtySgNodeTransform(); } }, + //when the content size of stencil is changed, the rendering will be wrong, because of the transform is called + //by no parent render command, in fact the parent rendercommand should be the render command of clippingNode + _dirtySgNodeTransform: function() { + this.node._sgNode._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty); + }, + _rebuildSceneGraph: function (newNode, oldNode) { newNode.setPosition(this.node._position); From 5379d0886f96512ae9850089102bc57e198cd373 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 14 Dec 2015 17:45:03 +0800 Subject: [PATCH 9/9] refine code --- cocos2d/core/components/CCMask.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 2b4fad4259..0e9f712710 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -85,7 +85,9 @@ var Mask = cc.Class({ //when the content size of stencil is changed, the rendering will be wrong, because of the transform is called //by no parent render command, in fact the parent rendercommand should be the render command of clippingNode _dirtySgNodeTransform: function() { - this.node._sgNode._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty); + if(!cc.sys.isNative) { + this.node._sgNode._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.transformDirty); + } }, _rebuildSceneGraph: function (newNode, oldNode) {