TVFocus.js 48.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109

var Common = require('Common');
var FocusInfo = require('FocusInfo');
//var AbstractTVFocus=require('AbstractTVFocus');


cc.Class({
    //name:"TVFocus",
    extends: cc.Component,
    //extends: cc.Node,  引擎团队的人不推荐这么做

    properties: {

        _cornerOuterRadius: 18,
        _cornerInnerRadius: 12,
        _screenWidth: Common.SCREEN_WIDTH,
        _screenHeight: Common.SCREEN_HEIGHT,
        _oScene: null,
        //_tvlink:null,
        //sprites:[],
        //nodes:[],
        //isShow:false

        /*
        {
            breath:[],
            cellTransform:[],  //move+scale
            containerTansfer[]
        }

        */




    },
    //由于addComponent时会新建Focus调用默认构造函数,其不支持参数输入,所以这个函数基本没用
    ctor: function (/*strName,oScene,fLeft,fTop,fObjectWidth,fObjectHeight,fScreenWidth,fScreenHeight,fCornerOuterRadius,fCornerInnerRadius*/) {
        //cc.log(this instanceof Sprite);    // true

        //参数处理
        let strName = arguments[0];
        let oScene = arguments[1];
        let fLeft = arguments[2];
        let fTop = arguments[3];
        let fObjectWidth = arguments[4];
        let fObjectHeight = arguments[5];
        let fScreenWidth = arguments[6];
        let fScreenHeight = arguments[7];
        let fCornerOuterRadius = arguments[8];
        let fCornerInnerRadius = arguments[9];

        this.name = (strName ? strName : "focusContainer");
        this._oScene = oScene;
        //this.width=fObjectWidth;
        //this.height=fObjectHeight;

        fLeft = (fLeft ? fLeft : 10);
        fTop = (fTop ? fTop : 10);
        fObjectWidth = (fObjectWidth ? fObjectWidth : 30);
        fObjectHeight = (fObjectHeight ? fObjectHeight : 30);


        this._screenWidth = (fScreenWidth ? fScreenWidth : Common.SCREEN_WIDTH);
        this._screenHeight = (fScreenHeight ? fScreenHeight : Common.SCREEN_HEIGHT);
        this._cornerOuterRadius = (fCornerOuterRadius ? fCornerOuterRadius : 18);
        this._cornerInnerRadius = (fCornerInnerRadius ? fCornerInnerRadius : 12);



        /*
        var oTransformedPosition=this.transformCoordinatesWeb2Cocos(fLeft,fTop,fObjectWidth,fObjectHeight);
        this.node.x=oTransformedPosition.x;
        this.node.y=oTransformedPosition.y;
        


        var urlFocus=null;
        var textureFocus = null;
        //1 2 3
        //4   6
        //7 8 9
        for (var i=1;i<=9;i++){
            this.node.children[i-1] = new cc.Node('focus_'+i);
            
            if (5==i){
                continue;
            }
            urlFocus = cc.url.raw('Texture/Focus/'+i+'.png');
            textureFocus = cc.textureCache.addImage(urlFocus);

           
            var spriteTemp = this.node.children[i-1].addComponent(cc.Sprite);
            spriteTemp.spriteFrame = new cc.SpriteFrame(textureFocus);
            
            //this.node.child[i-1].parent=this.node;
            this.node.children[i-1].x=i*20;

            if (2==i || 8==i){
                spriteTemp.fillType = cc.Sprite.FillType.HORIZONTAL;


            }else if (4==i || 6==i){
                spriteTemp.fillType = cc.Sprite.FillType.VERTICAL;

            }
        }
        //this.fly(fLeft,fTop,fObjectWidth,fObjectHeight,10,1.0);
        */
    },

    /**
     * bChangeTexture:某些情况下需要使用其他样式的焦点框
     */
    init: function (strName, oScene, fiCurrentFocus,//Left,fTop,fObjectWidth,fObjectHeight,
        fScreenWidth, fScreenHeight, fCornerOuterRadius, fCornerInnerRadius, fScaleFactor, bChangeTexture) {
        //TODO:这个函数里面是否要做onbeforeFocus和onAfterFocus的操作 --question from eva
        //cc.log(this instanceof Sprite);    // true
        try {
            if (strName) {
                this.name = strName;
            } else {
                cc.log('No Focus Name Specified');
                return;
            }

            if (oScene) {
                this._oScene = oScene;
            } else {
                cc.log('No Scene Specified for Focus');
            }

            fScaleFactor = fScaleFactor || fiCurrentFocus.getScaleFactor();
            if (null == fScaleFactor) {
                fScaleFactor = 1.0;
            }

            //旧的事件通知 好像不需要旧的事件通知
            // let eventBeforeFocus=new cc.Event.EventCustom('before_focus_change', true);
            // eventBeforeFocus.setUserData({ from: null, to: fiCurrentFocus});
            // this.node.dispatchEvent(eventBeforeFocus);
            // fScaleFactor = fScaleFactor || fiCurrentFocus.getScaleFactor();

            //this.width=fObjectWidth;
            //this.height=fObjectHeight;

            var fLeft = fiCurrentFocus.getLeft();
            var fTop = fiCurrentFocus.getTop();
            var fObjectWidth = fiCurrentFocus.getWidth();
            var fObjectHeight = fiCurrentFocus.getHeight();


            if (fScreenWidth) {
                this._screenWidth = fScreenWidth;
            }
            if (fScreenHeight) {
                this._screenHeight = fScreenHeight;
            }
            if (fCornerOuterRadius) {
                this._cornerOuterRadius = fCornerOuterRadius;
            }
            if (fCornerInnerRadius) {
                this._cornerInnerRadius = fCornerInnerRadius;
            }



            var oTransformedPosition = this.transformCoordinatesWeb2Cocos(fLeft, fTop, fObjectWidth, fObjectHeight);
            this.node.x = oTransformedPosition.x;
            this.node.y = oTransformedPosition.y;
            for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
                if (this._aNodeFocusCompany[c]) {
                    this._aNodeFocusCompany[c].x = oTransformedPosition.x;
                    this._aNodeFocusCompany[c].y = oTransformedPosition.y;
                }
            }

            var urlFocus = null;
            var textureFocus = null;
            //1 2 3
            //4   6
            //7 8 9
            for (var i = 1; i <= 9; i++) {
                //this.node.children[i-1] = new cc.Node('focus_'+i);
                this.node.addChild(new cc.Node('focus_' + i), 10);
                if (5 == i) {
                    continue;
                }
                if (bChangeTexture && (i == 2 || i == 4 || i == 6 || i == 8)) {
                    continue;
                }
                let spriteFocus = this.node.getChildByName('focus_' + i).addComponent(cc.Sprite);
                let strLoadImagePath = bChangeTexture ? 'Texture/Focus4/' + i + '' : 'Texture/Focus/' + i + '';
                Common.renderSpriteByLocalImage(strLoadImagePath, spriteFocus);
                spriteFocus.trim = false;
                spriteFocus.sizeMode = cc.Sprite.SizeMode.RAW;

                //this.node.child[i-1].parent=this.node;
                //this.node.getChildByName('focus_'+i).x= fLeft  fCornerOuterRadius-fCornerInnerRadius;
                //this.node.getChildByName('focus_'+i).y=0;

                var ftaScaleTo = null
                if (2 == i || 8 == i) {

                    //spriteTemp.sizeMode = cc.Sprite.SizeMode.CUSTOM;
                    //spriteTemp.type= cc.Sprite.Type.FILLED;
                    //spriteTemp.fillType = cc.Sprite.FillType.HORIZONTAL;
                    //spriteTemp.width=fObjectWidth-2*fCornerInnerRadius;
                    //this.node.children[i-1].width=fObjectWidth-2*fCornerInnerRadius;
                    //this.node.children[i-1].height=fCornerOuterRadius;
                    ftaScaleTo = cc.scaleTo(0, fScaleFactor * (fObjectWidth - 2 * fCornerInnerRadius), fScaleFactor * 1.0);

                } else if (4 == i || 6 == i) {
                    //spriteTemp.sizeMode = cc.Sprite.SizeMode.CUSTOM;
                    //spriteTemp.type= cc.Sprite.Type.FILLED;
                    //spriteTemp.fillType = cc.Sprite.FillType.VERTICAL;
                    //spriteTemp.height=fObjectHeight-2*fCornerInnerRadius;

                    //this.node.children[i-1].setContentSize();

                    //this.node.children[i-1].width=fCornerOuterRadius;
                    //this.node.children[i-1].height=fObjectHeight-2*fCornerInnerRadius;

                    ftaScaleTo = cc.scaleTo(0, fScaleFactor * 1.0, fScaleFactor * (fObjectHeight - 2 * fCornerInnerRadius));
                } else {
                    ftaScaleTo = cc.scaleTo(0, fScaleFactor, fScaleFactor);

                }
                ftaScaleTo.setTag(Common.FOCUS_CELL_TRANSFER);
                this.node.children[i - 1].stopActionByTag(Common.FOCUS_CELL_TRANSFER);
                this.node.children[i - 1].runAction(ftaScaleTo);

            }

            this.node.children[0].x = fScaleFactor * (-fObjectWidth / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[0].y = fScaleFactor * (fObjectHeight / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[1].x = 0;
            this.node.children[1].y = fScaleFactor * (fObjectHeight / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[2].x = fScaleFactor * (fObjectWidth / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[2].y = fScaleFactor * (fObjectHeight / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));

            this.node.children[3].x = fScaleFactor * (-fObjectWidth / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[3].y = 0;
            //this.node.children[4].x=0;
            //this.node.children[4].y=0;
            this.node.children[5].x = fScaleFactor * (fObjectWidth / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[5].y = 0;

            this.node.children[6].x = fScaleFactor * (-fObjectWidth / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[6].y = fScaleFactor * (-fObjectHeight / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[7].x = 0;
            this.node.children[7].y = fScaleFactor * (-fObjectHeight / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[8].x = fScaleFactor * (fObjectWidth / 2 + (fCornerOuterRadius / 2 - fCornerInnerRadius));
            this.node.children[8].y = fScaleFactor * (-fObjectHeight / 2 - (fCornerOuterRadius / 2 - fCornerInnerRadius));



            //放大 当前选中的Node
            var ftaScaleCurrentFocus = cc.scaleTo(0, fScaleFactor, fScaleFactor);
            ftaScaleCurrentFocus.setTag(Common.FEATURE_NODE_TRANSFER);

            //fiCurrentFocus.node.setLocalZOrder(40);

            //fiCurrentFocus.node.stopAllActions();
            //fiCurrentFocus.node.runAction(ftaScaleCurrentFocus);

            if (!fiCurrentFocus._bIgnoreZIndex) {
                fiCurrentFocus.node.zIndex = 40;
            }

            fiCurrentFocus.node.stopActionByTag(Common.FEATURE_NODE_TRANSFER);
            fiCurrentFocus.node.runAction(ftaScaleCurrentFocus);



            //开始呼吸动画
            var aiFocusBreath = cc.repeatForever(cc.sequence(cc.fadeTo(1, 100), cc.fadeTo(1, 255), cc.fadeTo(2, 255)));
            aiFocusBreath.setTag(Common.FOCUS_CONTAINER_BREATH);
            this.node.stopActionByTag(Common.FOCUS_CONTAINER_BREATH);
            this.node.runAction(aiFocusBreath);


            let eventOnFocus = new cc.Event.EventCustom('focus', true);
            eventOnFocus.setUserData({ from: null, to: fiCurrentFocus });
            this.node.dispatchEvent(eventOnFocus);

            //新的事件通知
            //this.node.emit('after_focus_change', { from: fiCurrentFocus, to: fiFocusTarget});
            // let eventAfterFocus=new cc.Event.EventCustom('after_focus_change', true);
            // eventAfterFocus.setUserData({ from: null, to: fiCurrentFocus});
            // this.node.dispatchEvent(eventAfterFocus);

            this._oScene.setCurrentFocus(fiCurrentFocus);
            this.node.zIndex = 999;
            //设置伴随的呼吸
            for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
                if (this._aNodeFocusCompany[c] && this._aNodeFocusCompany[c].opacity) {
                    let aiFocusCompanyBreath = cc.repeatForever(cc.sequence(cc.fadeTo(1, 100), cc.fadeTo(1, 255), cc.fadeTo(2, 255)));
                    aiFocusCompanyBreath.setTag("FOCUS_COMPANY_BREATH" + this._aNodeFocusCompany[c].name);
                    this._aNodeFocusCompany[c].stopAction(this._aNodeFocusCompany[c].getActionByTag("FOCUS_COMPANY_BREATH" + this._aNodeFocusCompany[c].name));
                    this._aNodeFocusCompany[c].runAction(aiFocusCompanyBreath);
                }
                this._aNodeFocusCompany[c].zIndex = 999;
            }

        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "init Error in TVFocus==>" + error);
            }
        }


    },


    // use this for initialization
    onLoad: function () {
        this._aNodeFocusCompany = [];
        cc.log("Focus onLoad...");

    },

    /*
    test: function(){

        var imgUrl1 = cc.url.raw('Texture/Focus/1.png');
        var texture1 = cc.textureCache.addImage(imgUrl1);
        this.node.getChildByName('focus_'+i).getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture1);

    },*/

    hide: function () {
        try {
            //this.node.opacity=0;
            this.node.children[0].opacity = 0;
            this.node.children[1].opacity = 0;
            this.node.children[2].opacity = 0;
            this.node.children[3].opacity = 0;
            this.node.children[4].opacity = 0;
            this.node.children[5].opacity = 0;
            this.node.children[6].opacity = 0;
            this.node.children[7].opacity = 0;
            this.node.children[8].opacity = 0;
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "hide Error in TVFocus==>" + error);
            }
        }

    },
    show: function () {
        try {
            //this.node.opacity=255;
            this.node.children[0].opacity = 255;
            this.node.children[1].opacity = 255;
            this.node.children[2].opacity = 255;
            this.node.children[3].opacity = 255;
            this.node.children[4].opacity = 255;
            this.node.children[5].opacity = 255;
            this.node.children[6].opacity = 255;
            this.node.children[7].opacity = 255;
            this.node.children[8].opacity = 255;
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "show Error in TVFocus==>" + error);
            }
        }

    },

    checkCompanyBreath: function () {
        try {
            for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
                if (this._aNodeFocusCompany[c]) {
                    if (this._aNodeFocusCompany[c].opacity) {
                        let aiFocusCompanyBreath = cc.repeatForever(cc.sequence(cc.fadeTo(1, 100), cc.fadeTo(1, 255), cc.fadeTo(2, 255)));
                        aiFocusCompanyBreath.setTag("FOCUS_COMPANY_BREATH" + this._aNodeFocusCompany[c].name);
                        this._aNodeFocusCompany[c].stopAction(this._aNodeFocusCompany[c].getActionByTag("FOCUS_COMPANY_BREATH" + this._aNodeFocusCompany[c].name));
                        this._aNodeFocusCompany[c].runAction(aiFocusCompanyBreath);
                    } else {
                        this._aNodeFocusCompany[c].stopAction(this._aNodeFocusCompany[c].getActionByTag("FOCUS_COMPANY_BREATH" + this._aNodeFocusCompany[c].name));
                    }
                }
            }
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "checkCompanyBreath Error in TVFocus==>" + error);
            }
        }

    },
    //分别处理9块区域 输入坐标为左上角所需
    fly: function (fLeft, fTop, fObjectWidth, fObjectHeight, fDuration, fScaleFactor) {
        try {
            //1 2 3
            //4   6
            //7 8 9
            var oTransformedPosition = this.transformCoordinatesWeb2Cocos(fLeft, fTop, fObjectWidth, fObjectHeight);
            var ftaContainerMoveTo = cc.moveTo(fDuration, oTransformedPosition.x, oTransformedPosition.y);

            ftaContainerMoveTo.setTag(Common.FOCUS_CONTAINER_TRANSFER);


            for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
                if (this._aNodeFocusCompany[c]) {
                    let ftaCompanyMoveTo = cc.moveTo(fDuration, oTransformedPosition.x, oTransformedPosition.y);
                    ftaCompanyMoveTo.setTag("FOCUS_COMPANY_TRANSFER" + this._aNodeFocusCompany[c].name);
                    this._aNodeFocusCompany[c].stopAction(this._aNodeFocusCompany[c].getActionByTag("FOCUS_COMPANY_TRANSFER" + this._aNodeFocusCompany[c].name));
                    this._aNodeFocusCompany[c].runAction(ftaCompanyMoveTo);
                }
            }




            var ftaMoveTo = [];
            var ftaScaleTo = null;

            var ftaCombined = [];
            ftaMoveTo[0] = cc.moveTo(fDuration,
                fScaleFactor * (-fObjectWidth / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                fScaleFactor * (fObjectHeight / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );

            ftaMoveTo[1] = cc.moveTo(fDuration,
                0,
                fScaleFactor * (fObjectHeight / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );

            ftaMoveTo[2] = cc.moveTo(fDuration,
                fScaleFactor * (fObjectWidth / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                fScaleFactor * (fObjectHeight / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );

            ftaMoveTo[3] = cc.moveTo(fDuration,
                fScaleFactor * (-fObjectWidth / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                0
            );

            //Nothing should be done for 4

            ftaMoveTo[5] = cc.moveTo(fDuration,
                fScaleFactor * (fObjectWidth / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                0
            );

            ftaMoveTo[6] = cc.moveTo(fDuration,
                fScaleFactor * (-fObjectWidth / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                fScaleFactor * (-fObjectHeight / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );
            ftaMoveTo[7] = cc.moveTo(fDuration,
                0,
                fScaleFactor * (-fObjectHeight / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );
            ftaMoveTo[8] = cc.moveTo(fDuration,
                fScaleFactor * (fObjectWidth / 2 + (this._cornerOuterRadius / 2 - this._cornerInnerRadius)),
                fScaleFactor * (-fObjectHeight / 2 - (this._cornerOuterRadius / 2 - this._cornerInnerRadius))
            );

            this.node.stopAction(this.node.getActionByTag(Common.FOCUS_CONTAINER_TRANSFER));
            this.node.runAction(ftaContainerMoveTo);




            for (var i = 1; i <= 9; i++) {

                if (5 == i) {
                    continue;
                }

                if (2 == i || 8 == i) {
                    ftaScaleTo = cc.scaleTo(fDuration, fScaleFactor * (fObjectWidth - 2 * this._cornerInnerRadius), fScaleFactor * 1.0);
                } else if (4 == i || 6 == i) {
                    ftaScaleTo = cc.scaleTo(fDuration, fScaleFactor * 1.0, fScaleFactor * (fObjectHeight - 2 * this._cornerInnerRadius));
                } else {
                    ftaScaleTo = cc.scaleTo(fDuration, fScaleFactor, fScaleFactor);
                }
                ftaCombined[i - 1] = cc.spawn(ftaMoveTo[i - 1], ftaScaleTo);
                ftaCombined[i - 1].setTag(Common.FOCUS_CELL_TRANSFER);
                this.node.children[i - 1].stopAction(this.node.children[i - 1].getActionByTag(Common.FOCUS_CELL_TRANSFER));
                this.node.children[i - 1].runAction(ftaCombined[i - 1]);
            }
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "fly Error in TVFocus==>" + error);
            }
        }


    },

    findTarget: function (oCurrentFocusInfo, aInFocusTargets, iStatus, iDirection) {

        try {
            if (null == oCurrentFocusInfo) {
                oCurrentFocusInfo = this._oScene.getCurrentFocusInfo();
            }

            if (null == aInFocusTargets) {
                aInFocusTargets = this._oScene.getFocusTargets()
            }

            var aFocusTargets = aInFocusTargets[iStatus];

            //var elFocusNow=document.getElementById(g_strFocusElementId);

            var fCurrentLeft = oCurrentFocusInfo.getLeft();
            var fCurrentTop = oCurrentFocusInfo.getTop();
            var fCurrentWidth = oCurrentFocusInfo.getWidth();
            var fCurrentHeight = oCurrentFocusInfo.getHeight();


            var oFocusTarget = null;  //node?
            var fDirectionWeight = 5.0;
            var fEvaluationRecord = 99999;

            //决定要搞哪一个
            if (Common.MOVE_DIRECTION_UP <= iDirection && iDirection <= Common.MOVE_DIRECTION_LEFT) {
                for (var key in aFocusTargets) { //for (var i=0;i<aFocusTargets.length;i++){
                    //if (aFocusTargets[i].id == g_strFocusElementId || !doesElementDisplay(aFocusTargets[i])) continue;


                    let fiByKey = aFocusTargets[key].getComponent(FocusInfo);
                    if (!fiByKey.getEnable()) {//不显示的不参与寻找
                        continue;
                    }

                    var fTargetLeft = fiByKey.getLeft();
                    var fTargetTop = fiByKey.getTop();
                    var fTargetWidth = fiByKey.getWidth();
                    var fTargetHeight = fiByKey.getHeight();

                    //权重计算   移动方向上距离*3+和移动方向垂直的方向中心距离差 的和最小为最近控件
                    var fDistanceOfEdge = 0.0; //移动方向边缘的距离
                    var fOffsetOfCenter = 0.0; //垂直移动方向两块区域中心的距离
                    var fOverlapWidth = 0.0;  //在移动方向上重叠的距离 复数为不重叠
                    var fSmallEdgeWidth = 0.0; //短的那个边缘的宽度

                    if (true) { //如果目标在限制区域内
                        switch (iDirection) {
                            case Common.MOVE_DIRECTION_UP:
                                fDistanceOfEdge = fCurrentTop - fTargetTop - fTargetHeight;
                                fOffsetOfCenter = Math.abs(fTargetLeft + fTargetWidth / 2 - fCurrentLeft - fCurrentWidth / 2);
                                fOverlapWidth = ((fCurrentLeft + fCurrentWidth - fTargetLeft - fTargetWidth >= 0) ? fTargetLeft + fTargetWidth : fCurrentLeft + fCurrentWidth)
                                    - ((fCurrentLeft - fTargetLeft >= 0) ? fCurrentLeft : fTargetLeft);
                                fSmallEdgeWidth = (fCurrentWidth < fTargetWidth) ? fCurrentWidth : fTargetWidth;
                                break;
                            case Common.MOVE_DIRECTION_DOWN:
                                fDistanceOfEdge = fTargetTop - fCurrentTop - fCurrentHeight;
                                fOffsetOfCenter = Math.abs(fTargetLeft + fTargetWidth / 2 - fCurrentLeft - fCurrentWidth / 2);
                                fOverlapWidth = ((fCurrentLeft + fCurrentWidth - fTargetLeft - fTargetWidth >= 0) ? fTargetLeft + fTargetWidth : fCurrentLeft + fCurrentWidth)
                                    - ((fCurrentLeft - fTargetLeft >= 0) ? fCurrentLeft : fTargetLeft);
                                fSmallEdgeWidth = (fCurrentWidth < fTargetWidth) ? fCurrentWidth : fTargetWidth;
                                break;
                            case Common.MOVE_DIRECTION_LEFT:
                                fDistanceOfEdge = fCurrentLeft - fTargetLeft - fTargetWidth;
                                fOffsetOfCenter = Math.abs(fTargetTop + fTargetHeight / 2 - fCurrentTop - fCurrentHeight / 2);
                                fOverlapWidth = ((fCurrentTop + fCurrentHeight - fTargetTop - fTargetHeight >= 0) ? fTargetTop + fTargetHeight : fCurrentTop + fCurrentHeight)
                                    - ((fCurrentTop - fTargetTop >= 0) ? fCurrentTop : fTargetTop);
                                fSmallEdgeWidth = (fCurrentHeight < fTargetHeight) ? fCurrentHeight : fTargetHeight;
                                break;
                            case Common.MOVE_DIRECTION_RIGHT:
                                fDistanceOfEdge = fTargetLeft - fCurrentLeft - fCurrentWidth;
                                fOffsetOfCenter = Math.abs(fTargetTop + fTargetHeight / 2 - fCurrentTop - fCurrentHeight / 2);
                                fOverlapWidth = ((fCurrentTop + fCurrentHeight - fTargetTop - fTargetHeight >= 0) ? fTargetTop + fTargetHeight : fCurrentTop + fCurrentHeight)
                                    - ((fCurrentTop - fTargetTop >= 0) ? fCurrentTop : fTargetTop);
                                fSmallEdgeWidth = (fCurrentHeight < fTargetHeight) ? fCurrentHeight : fTargetHeight;
                                break;
                        }

                        if (fDistanceOfEdge >= 0 /*&& fOffsetOfCenter<g_iBlockWidth*/) { //目标位置要在我前进的一侧(移动方向不能重叠),并且不能太偏离中心

                            //估值=距离目标的邻边垂直距离*方向权重+重心所在轴偏移量

                            var fEvaluation = -fiByKey.getFocusWeight() * (fOverlapWidth / fSmallEdgeWidth) + fDistanceOfEdge;
                            //cc.log(aFocusTargets[i].id+"==>  "+fEvaluation+"  =-20*("+fSmallEdgeWidth+"/"+fOverlapWidth+")"+"+"+fDistanceOfEdge);
                            //+fOffsetOfCenter*fDirectionWeight;
                            if (fEvaluationRecord > fEvaluation) {
                                fEvaluationRecord = fEvaluation;
                                //elFormerTarget=elFocusTarget;
                                //oFocusTarget=aFocusTargets[key];
                                oFocusTarget = fiByKey;

                            }
                        }
                    }
                    //elFocusTarget=FindNearestFocusTarget(strDirection,fFocusLeft,fFocusTop,fFocusWidth,fFocusHeight,fLeft,fTop,fWidth,fHeight);
                }

                //Log.warning("["+(elFormerTarget?elFormerTarget.id:"null")+","+(elFocusTarget?elFocusTarget.id:"null")+"]");    

                if (null == oFocusTarget) { //找不到目标 不移动,一般到了边界
                    cc.log("No Target Found: oFocusTarget = null...");
                    return null;
                }
            } else {
                cc.log("No Target Found: unavailable direction");
                return null
            }
            return oFocusTarget;
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "findTarget Error in TVFocus==>" + error);
            }
        }


    },

    transformCoordinatesWeb2Cocos: function (fLeft, fTop, fObjectWidth, fObjectHeight) {
        try {
            var oCocosCoordinates = {};

            oCocosCoordinates.x = fLeft + fObjectWidth / 2 - this._screenWidth / 2;
            oCocosCoordinates.y = this._screenHeight / 2 - fObjectHeight / 2 - fTop;
            return oCocosCoordinates;
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "transformCoordinatesWeb2Cocos Error in TVFocus==>" + error);
            }
        }

    },

    flyFocus: function (fiCurrentFocus, fiFocusTarget, iDirection, fScaleFactor, oScrollParameter, iDuration) {
        try {
            if (null == fiFocusTarget) {//todo:先判断这个是否更划得来
                //找不到目标的动画小交互
                //var blink1=cc.blink(0.6,20);
                //this.node.runAction(blink1);


                let aiJoggle = cc.repeat(
                    cc.sequence(
                        cc.rotateTo(0.02, -2),
                        cc.rotateTo(0.02, 0),
                        cc.rotateTo(0.02, 2),
                        cc.rotateTo(0.02, 0)
                    ),
                    4
                );
                aiJoggle.setTag(Common.FOCUS_CONTAINER_JOGGLE);
                //if (null!=this.node.getActionByTag(Common.FOCUS_CONTAINER_JOGGLE)){
                //    this.node.stopAction(Common.FOCUS_CONTAINER_JOGGLE);
                //}
                this.node.stopAction(this.node.getActionByTag(Common.FOCUS_CONTAINER_JOGGLE));
                this.node.runAction(aiJoggle);


                for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
                    if (this._aNodeFocusCompany[c] && this._aNodeFocusCompany[c].opacity) {//显示的情况下才抖动
                        let aiCompanyJoggle = cc.repeat(
                            cc.sequence(
                                cc.rotateTo(0.02, -2),
                                cc.rotateTo(0.02, 0),
                                cc.rotateTo(0.02, 2),
                                cc.rotateTo(0.02, 0)
                            ),
                            4
                        );
                        aiCompanyJoggle.setTag("FOCUS_COMPANY_JOGGLE" + this._aNodeFocusCompany[c].name);
                        this._aNodeFocusCompany[c].stopAction(this._aNodeFocusCompany[c].getActionByTag("FOCUS_COMPANY_JOGGLE" + this._aNodeFocusCompany[c].name));
                        this._aNodeFocusCompany[c].runAction(aiCompanyJoggle);
                    }
                }
                return 0;
            }

            if (null == fiCurrentFocus) {
                fiCurrentFocus = this._oScene.getCurrentFocusInfo();
            }

            fScaleFactor = fiFocusTarget.getScaleFactor() || fScaleFactor;
            if (null == fScaleFactor) {
                fScaleFactor = 1.0;
            }

            if (null == iDuration) {
                iDuration = Common.FOCUS_FLY_DURATION;
            }






            //是否是有效方向
            if (Common.MOVE_DIRECTION_UP <= iDirection && iDirection <= Common.MOVE_DIRECTION_LEFT) {

                //滚屏相关参数 elScroll,iScrollStep 如果都有效开始处理滚屏
                //oScrollParameter.element   需要滚动的元素 Object[Element]
                //oScrollParameter.step      滚动的距离 Integer
                //oScrollParameter.relation  滚动是否和焦点元素有关?  Integer [0|1]
                //oScrollParameter.direction 滚动方向  ['left'|'right'|'up'|'down']

                //旧的事件通知
                //this.node.dispachEvent('before_focus_change', { from: fiCurrentFocus, to: fiFocusTarget});
                let eventBeforeFocus = new cc.Event.EventCustom('before_focus_change', true);
                eventBeforeFocus.setUserData({ from: fiCurrentFocus, to: fiFocusTarget });
                this.node.dispatchEvent(eventBeforeFocus);


                let eventOnBlur = new cc.Event.EventCustom('blur', true);
                eventOnBlur.setUserData({ from: fiCurrentFocus, to: fiFocusTarget });
                this.node.dispatchEvent(eventOnBlur);



                //let eventOnFocus=new cc.Event.

                let nodeCurrent = fiCurrentFocus.node;//node;
                let nodeTarget = fiFocusTarget.node;//node;


                //if (fiCurrentFocus && fiCurrentFocus.onBlur && typeof fiCurrentFocus.onBlur =='function' ){
                //   fiCurrentFocus.onBlur();
                //}



                //处理因焦点移动导致的部分界面滑动
                let fXScrollStep = 0;
                let fYScrollStep = 0;
                let fXScrollTarget = 0; //新方法
                let fYScrollTarget = 0; //新方法
                if (null != oScrollParameter && null != oScrollParameter.node
                    && null != oScrollParameter.getStep() && null != oScrollParameter.getHasRelation()) {  //满足此条件才考虑界面滚动


                    //MOVE_DIRECTION_UP:0,
                    //MOVE_DIRECTION_RIGHT:1,
                    //MOVE_DIRECTION_DOWN:2,
                    //MOVE_DIRECTION_LEFT:3,
                    //默认反向
                    if (null == oScrollParameter.getDirection()) {
                        switch (iDirection) {
                            case Common.MOVE_DIRECTION_UP: oScrollParameter.setDirection(Common.MOVE_DIRECTION_DOWN); break;
                            case Common.MOVE_DIRECTION_RIGHT: oScrollParameter.setDirection(Common.MOVE_DIRECTION_LEFT); break;
                            case Common.MOVE_DIRECTION_DOWN: oScrollParameter.setDirection(Common.MOVE_DIRECTION_UP); break;
                            case Common.MOVE_DIRECTION_LEFT: oScrollParameter.setDirection(Common.MOVE_DIRECTION_RIGHT); break;
                        }
                    }
                    //Deprecated Start 
                    switch (oScrollParameter.getDirection()) {
                        case Common.MOVE_DIRECTION_UP:
                            fYScrollStep = oScrollParameter.getStep();
                            break;
                        case Common.MOVE_DIRECTION_DOWN:
                            fYScrollStep = -oScrollParameter.getStep();
                            break;
                        case Common.MOVE_DIRECTION_LEFT:
                            fXScrollStep = -oScrollParameter.getStep();
                            break;
                        case Common.MOVE_DIRECTION_RIGHT:
                            fXScrollStep = oScrollParameter.getStep();
                            break;

                    }
                    //let ftaMoveToScrollParameter = cc.moveTo(iDuration, 
                    //                   oScrollParameter.node.x+fXScrollStep,
                    //                    oScrollParameter.node.y-fYScrollStep
                    //                );
                    //Deprecated End



                    switch (oScrollParameter.getDirection()) { //正负在外面算好了
                        case Common.MOVE_DIRECTION_UP:
                            fYScrollTarget = oScrollParameter.getTargetPosition();
                            break;
                        case Common.MOVE_DIRECTION_DOWN:
                            fYScrollTarget = oScrollParameter.getTargetPosition();
                            break;
                        case Common.MOVE_DIRECTION_LEFT:
                            fXScrollTarget = oScrollParameter.getTargetPosition();
                            break;
                        case Common.MOVE_DIRECTION_RIGHT:
                            fXScrollTarget = oScrollParameter.getTargetPosition();
                            break;

                    }
                    let finished = cc.callFunc((oScrollParameter.callback ? oScrollParameter.callback : function () {
                        cc.log("do something");
                    }), this, oScrollParameter.scope);//todo:这里是否考虑要个回调
                    let ftaMoveToScrollParameter = cc.sequence(cc.moveTo(iDuration, fXScrollTarget, fYScrollTarget), finished);

                    ftaMoveToScrollParameter.setTag(Common.SCROLL_BY_FOCUS_CHANGE);


                    oScrollParameter.node.stopActionByTag(oScrollParameter.node.getActionByTag(Common.SCROLL_BY_FOCUS_CHANGE));
                    //oScrollParameter.node.stopAllActions();


                    oScrollParameter.node.runAction(ftaMoveToScrollParameter);
                    oScrollParameter.setDirection(null);
                    //oScrollParameter.node.x+=fXScrollStep;
                    //oScrollParameter.node.y-=fYScrollStep;



                }

                //由于浮点数变成坐标必须取整所以不可避免会形成误差,其中的+1 -1为了保证边框不留空隙
                //Target会比边框稍大

                //let fDestFocusLeft = iScaledTargetLeft - g_iFocusFrameWidth  + iXScrollStep + "px";
                //let fDestFocusTop = iScaledTargetTop - g_iFocusFrameHeight  + iYScrollStep + "px";
                //let fDestFocusWidth = iScaledTargetWidth + 2 * g_iFocusFrameWidth + "px";
                //let fDestFocusHeight = iScaledTargetHeight + 2 * g_iFocusFrameHeight + "px";


                //只要改掉相对Left Top 就可
                //此处需很小心处理和上下代码的关系
                /*
                if (null != oScrollParameter && null != oScrollParameter.node
                    && null != oScrollParameter.getStep() && null != oScrollParameter.getHasRelation()) {  //满足此条件才考虑界面滚动
                    let sizeVisible = cc.Director.getVisibleSize();
                    let fDestScrollElementLeft = oScrollParameter.node.x + fXScrollStep;
                    let fDestScrollElementTop = sizeVisible.height - oScrollParameter.node.y + fYScrollStep;

                    //这里还缺少动画 必须一起开始动
                    oScrollParameter.node.x=fDestScrollElementLeft;
                    oScrollParameter.node.y=oScrollParameter.node.y - fYScrollStep;
                }*/



                //准备好了所有数据  这里开始一起行动
                //if (g_fnOnBeforeFocusChange) {
                //  g_fnOnBeforeFocusChange(elFocusNow, elFocusTarget, strDirection);
                //}


                //按比例将焦点目标的区域进行缩放 得注意浮点数的问题



                let ftaScaleCurrentFocus = cc.scaleTo(iDuration, 1.0, 1.0);
                let ftaScaleFocusTarget = cc.scaleTo(iDuration, fScaleFactor, fScaleFactor);

                /*
                log("ArchorPoint:%f,%f,%f,%f", pfiCurrentFocus->node->getAnchorPoint().x, 
                    pfiCurrentFocus->node->getAnchorPoint().y,
                    pfiCurrentFocus->node->getAnchorPointInPoints().x,
                    pfiCurrentFocus->node->getAnchorPointInPoints().y );
                */

                /*
                //红点测试
                auto sprite1 = cocos2d::Sprite::create("image/red_point.png");
                sprite1->setPosition(0,0
                    //  pfiCurrentFocus->node->getAnchorPointInPoints().x
                    //, pfiCurrentFocus->node->getAnchorPointInPoints().y);
                
                pfiCurrentFocus->node->addChild(sprite1, 20, "PointFlag");
                */


                if (!fiCurrentFocus._bIgnoreZIndex) {
                    nodeCurrent.zIndex = 10;
                }
                if (!fiFocusTarget._bIgnoreZIndex) {
                    nodeTarget.zIndex = 40;
                }
                ftaScaleCurrentFocus.setTag(Common.FEATURE_NODE_TRANSFER);
                ftaScaleFocusTarget.setTag(Common.FEATURE_NODE_TRANSFER);



                //if (null!=nodeCurrent.getActionByTag(Common.FEATURE_NODE_TRANSFER)){
                //    nodeCurrent.stopAction(Common.FEATURE_NODE_TRANSFER);    
                //}
                //if (null!=nodeTarget.getActionByTag(Common.FEATURE_NODE_TRANSFER)){
                //    nodeTarget.stopAction(Common.FEATURE_NODE_TRANSFER);    
                //}

                nodeCurrent.stopAction(nodeCurrent.getActionByTag(Common.FEATURE_NODE_TRANSFER));
                nodeTarget.stopAction(nodeTarget.getActionByTag(Common.FEATURE_NODE_TRANSFER));

                nodeCurrent.runAction(ftaScaleCurrentFocus);
                nodeTarget.runAction(ftaScaleFocusTarget);

                let oScope = this;
                window.setTimeout(function () {
                    oScope.fly(fiFocusTarget.getLeft() + fXScrollStep, fiFocusTarget.getTop() + fYScrollStep,
                        fiFocusTarget.getWidth(), fiFocusTarget.getHeight(),
                        iDuration, fScaleFactor);
                }, fiFocusTarget.getFlyDelayTime());



                //if (fiTarget.onFocus && typeof fiTarget.onFocus =='function' ){
                //    fiTarget.onFocus();
                //}

                let eventOnFocus = new cc.Event.EventCustom('focus', true);
                eventOnFocus.setUserData({ from: fiCurrentFocus, to: fiFocusTarget });
                this.node.dispatchEvent(eventOnFocus);

                //新的事件通知
                //this.node.emit('after_focus_change', { from: fiCurrentFocus, to: fiFocusTarget});
                let eventAfterFocus = new cc.Event.EventCustom('after_focus_change', true);
                eventAfterFocus.setUserData({ from: fiCurrentFocus, to: fiFocusTarget });
                this.node.dispatchEvent(eventAfterFocus);

                //新的事件通知方式 是否科学有待检验
                //let eventFocusLeave=new cc.Event.EventCustom('focus_leave',true);
                //eventFocusLeave.setUserData({from:fiCurrentFocus,to:fiFocusTarget});
                //nodeCurrent.dispatchEvent(eventFocusLeave);

                //let eventFocusHover=new cc.Event.EventCustom('focus_hover',true);
                //eventFocusHover.setUserData({from:fiCurrentFocus,to:fiFocusTarget});
                //nodeTarget.dispatchEvent(eventFocusHover);


                this._oScene.setCurrentFocus(fiFocusTarget);

                //显示的伴随应该给它设置呼吸
                this.checkCompanyBreath();

                //计算完成以下开始完成所有动作
                //elFocusNow.style.zIndex = 0;
                //elFocusTarget.style.zIndex = 20;
                /*
                var elFocusContainer = document.getElementById("focus_container");
                //document.getElementById('view_port').style.left = destViewPortLeft;
                elFocusContainer.style.left = destFocusLeft;
                elFocusContainer.style.top = destFocusTop;
                //document.getElementById("focus5").style.width = destFocusWidth;
                //document.getElementById("focus5").style.height = destFocusHeight;
                elFocusContainer.style.width = destFocusWidth;
                elFocusContainer.style.height = destFocusHeight;
                */

                //if (g_fnOnAfterFocusChange) {
                //  g_fnOnAfterFocusChange(elFocusNow, elFocusTarget, strDirection);
                //}

                //总要先将前面那个复原
                //scaleElement(g_strFocusElementId, 1, 1);
                //g_strFocusElementId = elFocusTarget.id;

                return 1;

            } else {
                cc.log("No Target Found to Fly: Unavailable Direction");
                return 0;
            }
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "flyFocus Error in TVFocus==>" + error);
            }
        }



    },

    jumpFocus: function (fiCurrentFocus, fiFocusTarget, iDirection, fScaleFactor, oScrollParameter) {
        try {
            if (null == fiFocusTarget) {
                //找不到目标的动画小交互
                //var blink1=cc.blink(0.6,20);
                //this.node.runAction(blink1);

                let aiJoggle = cc.repeat(
                    cc.sequence(
                        cc.rotateTo(0.02, -2),
                        cc.rotateTo(0.02, 0),
                        cc.rotateTo(0.02, 2),
                        cc.rotateTo(0.02, 0)
                    ),
                    4
                );
                aiJoggle.setTag(Common.FOCUS_CONTAINER_JOGGLE);

                this.node.stopAction(this.node.getActionByTag(Common.FOCUS_CONTAINER_JOGGLE));
                this.node.runAction(aiJoggle);
                return 0;
            }

            fScaleFactor = fScaleFactor || fiFocusTarget.getScaleFactor();



            //是否是有效方向
            if (Common.MOVE_DIRECTION_UP <= iDirection && iDirection <= Common.MOVE_DIRECTION_LEFT) {

                //let eventBeforeFocus=new cc.Event.EventCustom('before_focus_change', true);
                //eventBeforeFocus.setUserData({ from: fiCurrentFocus, to: fiFocusTarget});
                //this.node.dispatchEvent(eventBeforeFocus);


                //处理因焦点移动导致的部分界面滑动
                let fXScrollStep = 0;
                let fYScrollStep = 0;

                var ftaScaleCurrentFocus = cc.scaleTo(Common.FOCUS_FLY_DURATION, 1.0, 1.0);
                var ftaScaleFocusTarget = cc.scaleTo(Common.FOCUS_FLY_DURATION, fScaleFactor, fScaleFactor);

                var nodeCurrent = fiCurrentFocus.node;//node;
                var nodeTarget = fiFocusTarget.node;//node;

                if (!fiCurrentFocus._bIgnoreZIndex) {
                    nodeCurrent.zIndex = 10;
                }
                if (!fiFocusTarget._bIgnoreZIndex) {
                    nodeTarget.zIndex = 40;
                }

                ftaScaleCurrentFocus.setTag(Common.FEATURE_NODE_TRANSFER);
                ftaScaleFocusTarget.setTag(Common.FEATURE_NODE_TRANSFER);

                nodeCurrent.stopAction(nodeCurrent.getActionByTag(Common.FEATURE_NODE_TRANSFER));
                nodeTarget.stopAction(nodeTarget.getActionByTag(Common.FEATURE_NODE_TRANSFER));

                nodeCurrent.runAction(ftaScaleCurrentFocus);
                nodeTarget.runAction(ftaScaleFocusTarget);


                this.fly(fiFocusTarget.getLeft(), fiFocusTarget.getTop(),
                    fiFocusTarget.getWidth(), fiFocusTarget.getHeight(),
                    0, fScaleFactor
                );


                //旧的事件通知
                //this.node.emit('after_focus_change', { from: fiCurrentFocus, to: fiFocusTarget});
                let eventAfterFocus = new cc.Event.EventCustom('after_focus_change', true);
                eventAfterFocus.setUserData({ from: fiCurrentFocus, to: fiFocusTarget });
                this.node.dispatchEvent(eventAfterFocus);

                //新的事件通知方式 是否科学有待检验
                //let eventFocusLeave=new cc.Event.EventCustom('focus_leave',true);
                //eventFocusLeave.setUserData({from:fiCurrentFocus,to:fiFocusTarget});
                //nodeCurrent.dispatchEvent(eventFocusLeave);

                //let eventFocusHover=new cc.Event.EventCustom('focus_hover',true);
                //eventFocusHover.setUserData({from:fiCurrentFocus,to:fiFocusTarget});
                //nodeTarget.dispatchEvent(eventFocusHover);

                this._oScene.setCurrentFocus(fiFocusTarget);

                return 1;

            } else {
                cc.log("No Target Found to Fly: Unavailable Direction");
                return 0;
            }
        } catch (error) {
            if (cc.sys.isNative) {
                jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "logInSceneI", "(Ljava/lang/String;)V", "jumpFocus Error in TVFocus==>" + error);
            }
        }



    },




    //跳向一个未来某一刻才会出现的Focus
    flyFocus2Fantasy: function (fiCurrentFocus, fiFocusTarget, iDirection, fScaleFactor, oScrollParameter) {

    },


    getCornerOuterRadius: function () {
        return this._cornerOuterRadius;
    },
    setCornerOuterRadius: function (cornerOuterRadius) {
        this._cornerOuterRadius = cornerOuterRadius;
    },
    getCornerInnerRadius: function () {
        return this._cornerInnerRadius;
    },
    setCornerInnerRadius: function (cornerInnerRadius) {
        this._cornerInnerRadius = cornerInnerRadius;
    },
    setCompany: function (node) {
        if (this._aNodeFocusCompany.indexOf(node) >= 0) {
            return;
        }
        this._aNodeFocusCompany.push(node);
    },
    removeCompany: function (node) {
        let index = this._aNodeFocusCompany.indexOf(node);
        this._aNodeFocusCompany.splice(index, 1);
    },
    setFocusTop: function (iTop) {
        this.node.y = iTop;
        for (let c = 0; c < this._aNodeFocusCompany.length; c++) {
            if (this._aNodeFocusCompany[c]) {
                this._aNodeFocusCompany[c].y = iTop;
            }
        }
    },





    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});