Skip to content

Commit bd07572

Browse files
committed
#14836 layout scale9Sprite error
1 parent bc26192 commit bd07572

File tree

1 file changed

+38
-20
lines changed

1 file changed

+38
-20
lines changed

extensions/cocostudio/loader/parsers/timelineParser-2.x.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,8 @@
261261

262262
widget.setTag(json["Tag"] || 0);
263263

264-
var touchEnabled = json["TouchEnable"];
265-
if(touchEnabled)
266-
widget.setTouchEnabled(true);
264+
var touchEnabled = json["TouchEnable"] || false;
265+
widget.setTouchEnabled(touchEnabled);
267266

268267
// -- var frameEvent = json["FrameEvent"];
269268

@@ -387,11 +386,31 @@
387386
if(backGroundScale9Enabled != null)
388387
widget.setBackGroundImageScale9Enabled(backGroundScale9Enabled);
389388

390-
var scale9OriginX = json["Scale9OriginX"] || 0;
391-
var scale9OriginY = json["Scale9OriginY"] || 0;
389+
var opacity = json["Alpha"] || 255;
390+
widget.setOpacity(opacity);
392391

393-
var scale9Width = json["Scale9Width"] || 0;
394-
var scale9Height = json["Scale9Height"] || 0;
392+
loadTexture(json["FileData"], resourcePath, function(path, type){
393+
widget.setBackGroundImage(path, type);
394+
});
395+
396+
if(backGroundScale9Enabled){
397+
var scale9OriginX = json["Scale9OriginX"] || 0;
398+
var scale9OriginY = json["Scale9OriginY"] || 0;
399+
400+
var scale9Width = json["Scale9Width"] || 0;
401+
var scale9Height = json["Scale9Height"] || 0;
402+
403+
widget.setBackGroundImageCapInsets(cc.rect(
404+
scale9OriginX, scale9OriginY, scale9Width, scale9Height
405+
));
406+
407+
setContentSize(widget, json["Size"]);
408+
}else{
409+
if (!widget.isIgnoreContentAdaptWithSize()){
410+
setContentSize(widget, json["Size"]);
411+
}
412+
413+
}
395414

396415
var bgStartColor = json["FirstColor"];
397416
var bgEndColor = json["EndColor"];
@@ -407,10 +426,6 @@
407426
if(colorVector != null)
408427
widget.setBackGroundColorVector(cc.p(colorVector["ScaleX"], colorVector["ScaleY"]));
409428

410-
loadTexture(json["FileData"], resourcePath, function(path, type){
411-
widget.setBackGroundImage(path, type);
412-
});
413-
414429
return widget;
415430
};
416431

@@ -481,7 +496,7 @@
481496
var path = fontResource["Path"];
482497
//resoutceType = fontResource["Type"];
483498
if(path != null){
484-
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
499+
if (cc.sys.isNative) {
485500
fontName = cc.path.join(cc.loader.resPath, resourcePath, path);
486501
} else {
487502
fontName = path.match(/([^\/]+)\.ttf/);
@@ -542,10 +557,6 @@
542557
if(fontName != null)
543558
widget.setTitleFontName(fontName);
544559

545-
var displaystate = getParam(json["DisplayState"], true);
546-
widget.setBright(displaystate);
547-
widget.setEnabled(displaystate);
548-
549560
var textColor = json["TextColor"];
550561
if(textColor != null)
551562
widget.setTitleColor(getColor(textColor));
@@ -560,17 +571,22 @@
560571
widget.loadTextureDisabled(path, type);
561572
});
562573

574+
var displaystate = getParam(json["DisplayState"], true);
575+
widget.setBright(displaystate);
576+
widget.setEnabled(displaystate);
577+
578+
var fontResource = json["FontResource"];
563579
if(fontResource != null){
564580
var path = fontResource["Path"];
565581
//resoutceType = fontResource["Type"];
566582
if(path != null){
567-
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
583+
if (cc.sys.isNative) {
568584
fontName = cc.path.join(cc.loader.resPath, resourcePath, path);
569585
} else {
570586
fontName = path.match(/([^\/]+)\.ttf/);
571587
fontName = fontName ? fontName[1] : "";
572588
}
573-
widget._labelRenderer.setFontName(fontName);
589+
widget.setTitleFontName(fontName);
574590
}
575591
}
576592

@@ -1045,7 +1061,7 @@
10451061
var path = fontResource["Path"];
10461062
//resoutceType = fontResource["Type"];
10471063
if(path != null){
1048-
if (cc.sys.isNative && cc.sys.os == cc.sys.OS_ANDROID) {
1064+
if (cc.sys.isNative) {
10491065
fontName = cc.path.join(cc.loader.resPath, resourcePath, path);
10501066
} else {
10511067
fontName = path.match(/([^\/]+)\.ttf/);
@@ -1064,7 +1080,9 @@
10641080

10651081
if (!widget.isIgnoreContentAdaptWithSize())
10661082
setContentSize(widget, json["Size"]);
1067-
//widget.getVirtualRenderer().setLineBreakWithoutSpace(true);
1083+
1084+
if (cc.sys.isNative)
1085+
widget.getVirtualRenderer().setLineBreakWithoutSpace(true);
10681086

10691087
return widget;
10701088

0 commit comments

Comments
 (0)