From ae1d0cea7110bda9d4fda5862afe8b5f4004bbb5 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 1 Mar 2016 11:27:51 +0800 Subject: [PATCH] fix blend serialization for sprite --- cocos2d/core/components/CCSprite.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/components/CCSprite.js b/cocos2d/core/components/CCSprite.js index 9edcec581b..9fa02d6793 100644 --- a/cocos2d/core/components/CCSprite.js +++ b/cocos2d/core/components/CCSprite.js @@ -75,7 +75,7 @@ var Sprite = cc.Class({ }, ctor: function() { - this._blendFunc = cc.BlendFunc.ALPHA_NON_PREMULTIPLIED; + this._blendFunc = new cc.BlendFunc(this._srcBlendFactor, this._dstBlendFactor); }, properties: { @@ -92,6 +92,8 @@ var Sprite = cc.Class({ _fillStart: 0, _fillRange: 0, _isTrimmedMode: true, + _srcBlendFactor: BlendFactor.SRC_ALPHA, + _dstBlendFactor: BlendFactor.ONE_MINUS_SRC_ALPHA, /** * The Sprite Atlas. * @property _atlas @@ -215,9 +217,10 @@ var Sprite = cc.Class({ */ srcBlendFactor: { get: function() { - return this._blendFunc.src; + return this._srcBlendFactor; }, set: function(value) { + this._srcBlendFactor = value; this._blendFunc.src = value; this._sgNode.setBlendFunc(this._blendFunc); }, @@ -232,9 +235,10 @@ var Sprite = cc.Class({ */ dstBlendFactor: { get: function() { - return this._blendFunc.dst; + return this._dstBlendFactor; }, set: function(value) { + this._dstBlendFactor = value; this._blendFunc.dst = value; this._sgNode.setBlendFunc(this._blendFunc); }, @@ -567,6 +571,8 @@ var Sprite = cc.Class({ sgNode.setFillStart(this._fillStart); sgNode.setFillRange(this._fillRange); sgNode.enableTrimmedContentSize(this._isTrimmedMode); + this._blendFunc.src = this._srcBlendFactor; + this._blendFunc.dst = this._dstBlendFactor; sgNode.setBlendFunc(this._blendFunc); },