Skip to content

Commit 6a0a9c5

Browse files
Merge pull request #3440 from zilongshanren/fix-uiscale9sprite-retina-display
fix uiscale9sprite content scale9 factor issue
2 parents e94ab0c + d6b3344 commit 6a0a9c5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

extensions/ccui/base-classes/UIScale9Sprite.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ var simpleQuadGenerator = {
136136
var atlasWidth = spriteFrame._texture._pixelsWide;
137137
var atlasHeight = spriteFrame._texture._pixelsHigh;
138138
var textureRect = spriteFrame._rect;
139+
textureRect = cc.rectPointsToPixels(textureRect);
139140

140141
if (uvs.length < 8) {
141142
dataPool.put(uvs);
@@ -254,12 +255,15 @@ var scale9QuadGenerator = {
254255
var leftWidth, centerWidth, rightWidth;
255256
var topHeight, centerHeight, bottomHeight;
256257
var textureRect = spriteFrame._rect;
258+
textureRect = cc.rectPointsToPixels(textureRect);
259+
rect = cc.rectPointsToPixels(rect);
260+
var scale = cc.contentScaleFactor();
257261

258-
leftWidth = insetLeft;
259-
rightWidth = insetRight;
262+
leftWidth = insetLeft * scale;
263+
rightWidth = insetRight * scale;
260264
centerWidth = rect.width - leftWidth - rightWidth;
261-
topHeight = insetTop;
262-
bottomHeight = insetBottom;
265+
topHeight = insetTop * scale;
266+
bottomHeight = insetBottom * scale;
263267
centerHeight = rect.height - topHeight - bottomHeight;
264268

265269
if (uvs.length < 32) {

0 commit comments

Comments
 (0)