• cocos jsb工程转html 工程


    1 CCBoot.js

    prepare方法:注掉下面这行,先加载moduleConfig中的脚本后加载user脚本

    //newJsList = newJsList.concat(jsList); //pengyingh 17 2 20 load user js in main.js

    2 main.js 加载user js

    cc.game.onStart = function(){
        console.log("cc.game.onStart");
        //load resources
        if(cc.sys.isNative) {
            cc.view.enableRetina(false);
            cc.view.adjustViewPort(true);
            cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL);
            cc.view.resizeWithBrowserSize(true);
            //设置本地资源查找目录
            var searchPaths = jsb.fileUtils.getSearchPaths();
            searchPaths.push('res');
            jsb.fileUtils.setSearchPaths(searchPaths);
            cc.LoaderScene.preload(g_resources, function () {
                cc.director.runScene(new HelloWorldScene());
            }, this);
        }
        else {
            cc.loader.resPath = "res/";
            cc.view.enableRetina(false);
            cc.loader.loadJsWithImg(cc.game.config.jsList, function (err) {
                if (err) throw new Error(err);
                cc.view.adjustViewPort(true);
                cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL);
                cc.view.resizeWithBrowserSize(true);
                cc.LoaderScene.preload(g_resources, function () {
                    cc.director.runScene(new HelloWorldScene());
                }, this);
            });
        }
    };

    3修改 load.js 中的_dirname方法 返回空

      _dirname: function(path){return "";//pengyingh 17 2 20
            var arr = path.match(this._dirnameReg);
            return (arr && arr[0]) ? arr[0] : "";
        },

    4 部分粒子加载报错卡死,添加纠错,暂时未解决如何显示此类粒子,默认粒子可以显示

    修改gzip.js中的cc.Codec.GZip.gunzip方法

    cc.Codec.GZip.gunzip = function (string) {//pengyingh 17 2 20
        if (string.constructor === Array) {
        } else if (string.constructor === String) {
        }
        var gzip = new cc.Codec.GZip(string);
        if ( gzip.gunzip()[0])
          return gzip.gunzip()[0][0];
        else return [];
    };

     5 如果想使用spine  在project.json 下的modules 中添加spine或者extensions

    但是spine播放有bug 不能loop播放,部分图片会丢失

    6 补充: ccui.ScrollView 的setScrollBarEnabled等jsb方法不能用了 cc.sys.isNative 用在native版本和web版的方法判断,工程入口是index.html 文件

  • 相关阅读:
    SDU暑期集训排位(8)
    hdu1423 最长公共上升子序列
    poj2385 Apple Catching (线性dp)
    hdu5857 Median(模拟)
    hdu5858 Hard problem(求两圆相交面积)
    shuoj 1 + 2 = 3? (二分+数位dp)
    Codeforces Round #460 (Div. 2) B Perfect Number(二分+数位dp)
    hdu4734 F(x)(数位dp)
    hdu3709 Balanced Number (数位dp)
    hdu3652 B-number(数位dp)
  • 原文地址:https://www.cnblogs.com/pengyingh/p/6420401.html
Copyright © 2020-2023  润新知