Skip to content

Commit cfbb0c7

Browse files
author
pandamicro
committed
Force reset texture rect when sprite texture changed
1 parent e5fe5bb commit cfbb0c7

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,19 @@
230230

231231
proto._setTexture = function (texture) {
232232
var node = this._node;
233-
// If batchnode, then texture id should be the same
234-
if (node._batchNode) {
235-
if (node._batchNode.texture !== texture) {
236-
cc.log(cc._LogInfos.Sprite_setTexture);
237-
return;
238-
}
239-
} else {
240-
if (node._texture !== texture) {
241-
node._textureLoaded = texture ? texture._textureLoaded : false;
242-
node._texture = texture;
243-
this._updateBlendFunc();
244-
245-
if (node._textureLoaded) {
246-
// Force refresh the render command list
247-
cc.renderer.childrenOrderDirty = true;
248-
}
233+
if (node._texture !== texture) {
234+
node._textureLoaded = texture ? texture._textureLoaded : false;
235+
node._texture = texture;
236+
237+
// Update texture rect and blend func
238+
var texSize = texture._contentSize;
239+
var rect = cc.rect(0, 0, texSize.width, texSize.height);
240+
node.setTextureRect(rect);
241+
this._updateBlendFunc();
242+
243+
if (node._textureLoaded) {
244+
// Force refresh the render command list
245+
cc.renderer.childrenOrderDirty = true;
249246
}
250247
}
251248
};

0 commit comments

Comments
 (0)