Skip to content

Commit 0255a55

Browse files
authored
Merge pull request #3361 from VisualSJ/develop
Fixed a bug about s9sprite updateSprite rect
2 parents c55c739 + 4398ce1 commit 0255a55

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

extensions/ccui/base-classes/UIScale9Sprite.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -876,24 +876,26 @@ ccui.Scale9Sprite = cc.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprit
876876
return false;
877877
}
878878

879-
var spriteFrame = sprite.getSpriteFrame();
880-
if (spriteFrame && cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
881-
spriteFrameRotated = false;
882-
spriteRect = { x: 0, y: 0, height: spriteRect.height, width: spriteRect.width }
883-
}
884-
885879
this._scale9Image = sprite;
886880
if(!this._scale9Image) return false;
881+
var tmpTexture = this._scale9Image.getTexture();
882+
this._textureLoaded = tmpTexture && tmpTexture.isLoaded();
883+
884+
var spriteFrame = sprite.getSpriteFrame();
885+
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
886+
// Clipping will reset the properties - canvas mode
887+
if (spriteFrame && tmpTexture._htmlElementObj instanceof window.HTMLCanvasElement) {
888+
spriteFrameRotated = false;
889+
spriteRect = { x: 0, y: 0, height: spriteRect.height, width: spriteRect.width }
890+
}
891+
}
887892

888893
var opacity = this.getOpacity();
889894
var color = this.getColor();
890895
this._renderers.length = 0;
891896
var rect = spriteRect;
892897
var size = originalSize;
893898

894-
var tmpTexture = this._scale9Image.getTexture();
895-
this._textureLoaded = tmpTexture && tmpTexture.isLoaded();
896-
897899
if(cc._rectEqualToZero(rect)) {
898900
var textureSize = tmpTexture.getContentSize();
899901
rect = cc.rect(0, 0, textureSize.width, textureSize.height);

0 commit comments

Comments
 (0)