Skip to content

Commit 8a3b0b4

Browse files
committed
fix uiscale9sprite content scale9 factor issue
1 parent eb8e61d commit 8a3b0b4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

extensions/ccui/base-classes/UIScale9Sprite.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,15 @@ var scale9QuadGenerator = {
254254
var leftWidth, centerWidth, rightWidth;
255255
var topHeight, centerHeight, bottomHeight;
256256
var textureRect = spriteFrame._rect;
257+
textureRect = cc.rectPointsToPixels(textureRect);
258+
rect = cc.rectPointsToPixels(rect);
259+
var scale = cc.contentScaleFactor();
257260

258-
leftWidth = insetLeft;
259-
rightWidth = insetRight;
261+
leftWidth = insetLeft * scale;
262+
rightWidth = insetRight * scale;
260263
centerWidth = rect.width - leftWidth - rightWidth;
261-
topHeight = insetTop;
262-
bottomHeight = insetBottom;
264+
topHeight = insetTop * scale;
265+
bottomHeight = insetBottom * scale;
263266
centerHeight = rect.height - topHeight - bottomHeight;
264267

265268
if (uvs.length < 32) {

0 commit comments

Comments
 (0)