|
526 | 526 |
|
527 | 527 | var widget = new ccui.Button();
|
528 | 528 |
|
529 |
| - this.widgetAttributes(widget, json); |
| 529 | + loadTexture(json["NormalFileData"], resourcePath, function(path, type){ |
| 530 | + widget.loadTextureNormal(path, type); |
| 531 | + }); |
| 532 | + loadTexture(json["PressedFileData"], resourcePath, function(path, type){ |
| 533 | + widget.loadTexturePressed(path, type); |
| 534 | + }); |
| 535 | + loadTexture(json["DisabledFileData"], resourcePath, function(path, type){ |
| 536 | + widget.loadTextureDisabled(path, type); |
| 537 | + }); |
530 | 538 |
|
531 | 539 | var scale9Enabled = getParam(json["Scale9Enable"], false);
|
532 |
| - if(scale9Enabled){ |
| 540 | + if(scale9Enabled) { |
533 | 541 | widget.setScale9Enabled(scale9Enabled);
|
534 |
| - widget.setUnifySizeEnabled(false); |
535 |
| - widget.ignoreContentAdaptWithSize(false); |
536 |
| - |
537 |
| - var capInsets = cc.rect( |
538 |
| - json["Scale9OriginX"] || 0, |
539 |
| - json["Scale9OriginY"] || 0, |
540 |
| - json["Scale9Width"] || 0, |
541 |
| - json["Scale9Height"] || 0 |
542 |
| - ); |
543 |
| - |
544 |
| - widget.setCapInsets(capInsets); |
545 |
| - |
546 | 542 | }
|
547 | 543 |
|
548 |
| - setContentSize(widget, json["Size"]); |
549 |
| - |
550 | 544 | var text = json["ButtonText"];
|
551 | 545 | if(text != null)
|
552 | 546 | widget.setTitleText(text);
|
|
563 | 557 | if(textColor != null)
|
564 | 558 | widget.setTitleColor(getColor(textColor));
|
565 | 559 |
|
566 |
| - loadTexture(json["NormalFileData"], resourcePath, function(path, type){ |
567 |
| - widget.loadTextureNormal(path, type); |
568 |
| - }); |
569 |
| - loadTexture(json["PressedFileData"], resourcePath, function(path, type){ |
570 |
| - widget.loadTexturePressed(path, type); |
571 |
| - }); |
572 |
| - loadTexture(json["DisabledFileData"], resourcePath, function(path, type){ |
573 |
| - widget.loadTextureDisabled(path, type); |
574 |
| - }); |
575 |
| - |
576 | 560 | var displaystate = getParam(json["DisplayState"], true);
|
577 | 561 | widget.setBright(displaystate);
|
578 | 562 | widget.setEnabled(displaystate);
|
|
591 | 575 | widget.setTitleFontName(fontName);
|
592 | 576 | }
|
593 | 577 | }
|
| 578 | + this.widgetAttributes(widget, json); |
| 579 | + |
| 580 | + if(scale9Enabled) { |
| 581 | + widget.setUnifySizeEnabled(false); |
| 582 | + widget.ignoreContentAdaptWithSize(false); |
| 583 | + var capInsets = cc.rect( |
| 584 | + json["Scale9OriginX"] || 0, |
| 585 | + json["Scale9OriginY"] || 0, |
| 586 | + json["Scale9Width"] || 0, |
| 587 | + json["Scale9Height"] || 0 |
| 588 | + ); |
| 589 | + widget.setCapInsets(capInsets); |
| 590 | + |
| 591 | + } |
| 592 | + |
| 593 | + setContentSize(widget, json["Size"]); |
594 | 594 |
|
595 | 595 | return widget;
|
596 | 596 |
|
|
0 commit comments