diff --git a/cocos2d/core/components/CCSpriteDistortion.js b/cocos2d/core/components/CCSpriteDistortion.js index d12a370de2..d673c19e36 100644 --- a/cocos2d/core/components/CCSpriteDistortion.js +++ b/cocos2d/core/components/CCSpriteDistortion.js @@ -65,6 +65,9 @@ var SpriteDistortion = cc.Class({ set:function(value) { this._distortionOffset.x = value.x; this._distortionOffset.y = value.y; + if(this._spriteSGNode) { + this._spriteSGNode.setDistortionOffset(this._distortionOffset); + } } }, @@ -84,6 +87,9 @@ var SpriteDistortion = cc.Class({ set:function(value) { this._distortionTiling.x = value.x; this._distortionTiling.y = value.y; + if(this._spriteSGNode) { + this._spriteSGNode.setDistortionTiling(this._distortionTiling); + } } }, }, @@ -93,8 +99,8 @@ var SpriteDistortion = cc.Class({ var sgNode = this._spriteSGNode = sprite && sprite._sgNode; if(this._spriteSGNode) { sgNode.setState(cc.Scale9Sprite.state.DISTORTION); - sgNode._distortionOffset = this._distortionOffset; - sgNode._distortionTiling = this._distortionTiling; + sgNode.setDistortionOffset(this._distortionOffset); + sgNode.setDistortionTiling(this._distortionTiling); } }, diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js index 255ccaa790..6906444eb8 100644 --- a/cocos2d/core/sprites/CCScale9Sprite.js +++ b/cocos2d/core/sprites/CCScale9Sprite.js @@ -1134,6 +1134,26 @@ cc.Scale9Sprite = _ccsg.Node.extend({ } }, + setDistortionTiling: function(valueOrX, y) { + if(y == undefined) { + y = valueOrX.y; + valueOrX = valueOrX.x; + } + this._distortionTiling = this._distortionTiling || cc.v2(0,0); + this._distortionTiling.x = valueOrX; + this._distortionTiling.y = y; + }, + + setDistortionOffset: function(valueOrX, y) { + if(y == undefined) { + y = valueOrX.y; + valueOrX = valueOrX.x; + } + this._distortionOffset = this._distortionOffset || cc.v2(0,0); + this._distortionOffset.x = valueOrX; + this._distortionOffset.y = y; + }, + getFillCenter: function() { return cc.v2(this._fillCenter); },