Skip to content

Commit f66d3fe

Browse files
committed
#14843 Fixed ColorFrame throw error
1 parent 0236a39 commit f66d3fe

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@
216216
frames.forEach(function(frameData){
217217
var frame = item.handle(frameData, resourcePath);
218218
frame.setFrameIndex(frameData["FrameIndex"]);
219-
frame.setTween(frameData["Tween"]);
219+
var tween = frameData["Tween"] != null ? frameData["Tween"] : true;
220+
frame.setTween(tween);
220221
timeline.addFrame(frame);
221222
});
222223
}

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@
380380
widget.setBackGroundColorType(colorType);
381381

382382
var bgColorOpacity = getParam(json["BackColorAlpha"], 255);
383-
widget.setBackGroundColorOpacity(bgColorOpacity);
383+
if(bgColorOpacity != null)
384+
widget.setBackGroundColorOpacity(bgColorOpacity);
384385

385386
var backGroundScale9Enabled = json["Scale9Enable"];
386387
if(backGroundScale9Enabled != null)
@@ -490,7 +491,6 @@
490491
if(isCustomSize != null)
491492
widget.ignoreContentAdaptWithSize(!isCustomSize);
492493

493-
//todo check it
494494
var fontResource = json["FontResource"];
495495
if(fontResource != null){
496496
var path = fontResource["Path"];
@@ -647,22 +647,25 @@
647647
widget.setBackGroundColorType(colorType);
648648

649649
var bgColorOpacity = json["BackColorAlpha"];
650-
if(bgColorOpacity)
650+
if(bgColorOpacity != null)
651651
widget.setBackGroundColorOpacity(bgColorOpacity);
652652

653653
var backGroundScale9Enabled = json["Scale9Enable"];
654654
if(backGroundScale9Enabled){
655655
widget.setBackGroundImageScale9Enabled(true);
656-
}
657656

658-
var scale9OriginX = json["Scale9OriginX"] || 0;
659-
var scale9OriginY = json["Scale9OriginY"] || 0;
660657

661-
var scale9Width = json["Scale9Width"] || 0;
662-
var scale9Height = json["Scale9Height"] || 0;
663-
664-
//todo please check it
665-
setContentSize(widget, json["Size"]);
658+
var scale9OriginX = json["Scale9OriginX"] || 0;
659+
var scale9OriginY = json["Scale9OriginY"] || 0;
660+
var scale9Width = json["Scale9Width"] || 0;
661+
var scale9Height = json["Scale9Height"] || 0;
662+
widget.setBackGroundImageCapInsets(cc.rect(
663+
scale9OriginX, scale9OriginY, scale9Width, scale9Height
664+
));
665+
setContentSize(widget, json["Size"]);
666+
}else if(!widget.isIgnoreContentAdaptWithSize()){
667+
setContentSize(widget, json["Size"]);
668+
}
666669

667670
var firstColor = json["FirstColor"];
668671
var endColor = json["EndColor"];
@@ -857,7 +860,8 @@
857860
var colorVector = json["ColorVector"];
858861
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
859862
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
860-
widget.setBackGroundColorOpacity(bgColorOpacity);
863+
if(bgColorOpacity != null)
864+
widget.setBackGroundColorOpacity(bgColorOpacity);
861865

862866
loadTexture(json["FileData"], resourcePath, function(path, type){
863867
widget.setBackGroundImage(path, type);
@@ -952,7 +956,8 @@
952956
var colorVector = json["ColorVector"];
953957
if(colorVector != null && colorVector["ScaleX"] != null && colorVector["ScaleY"] != null)
954958
widget.setBackGroundColorVector(colorVector["ScaleX"], colorVector["ScaleY"]);
955-
widget.setBackGroundColorOpacity(bgColorOpacity);
959+
if(bgColorOpacity != null)
960+
widget.setBackGroundColorOpacity(bgColorOpacity);
956961

957962

958963
loadTexture(json["FileData"], resourcePath, function(path, type){
@@ -1078,11 +1083,12 @@
10781083
if(color != null)
10791084
widget.setTextColor(getColor(color));
10801085

1081-
if (!widget.isIgnoreContentAdaptWithSize())
1086+
if (!widget.isIgnoreContentAdaptWithSize()){
10821087
setContentSize(widget, json["Size"]);
1088+
if (cc.sys.isNative)
1089+
widget.getVirtualRenderer().setLineBreakWithoutSpace(true);
1090+
}
10831091

1084-
if (cc.sys.isNative)
1085-
widget.getVirtualRenderer().setLineBreakWithoutSpace(true);
10861092

10871093
return widget;
10881094

0 commit comments

Comments
 (0)