diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js index 831d628a2b..ac7c90ab6d 100644 --- a/cocos2d/core/components/CCMask.js +++ b/cocos2d/core/components/CCMask.js @@ -242,13 +242,11 @@ var Mask = cc.Class({ } }, - onEnable: function () { - if (this.type === MaskType.IMAGE_STENCIL && - cc._renderType !== cc.game.RENDER_TYPE_WEBGL && !CC_JSB) { - cc.warnID(4200); - return; - } + __preload: function () { this._refreshStencil(); + }, + + onEnable: function () { this._super(); this.node.on('size-changed', this._refreshStencil, this); this.node.on('anchor-changed', this._refreshStencil, this); @@ -272,6 +270,13 @@ var Mask = cc.Class({ }, _refreshStencil: function () { + // Check whether the conditions are met + if (this.type === MaskType.IMAGE_STENCIL && + cc._renderType !== cc.game.RENDER_TYPE_WEBGL && !CC_JSB) { + cc.warnID(4200); + return; + } + var contentSize = this.node.getContentSize(); var anchorPoint = this.node.getAnchorPoint(); var stencil = this._clippingStencil;