• Cocos2d-JS v3.0 alpha 导入 cocostudio的ui配置


    1、在新项目的根文件夹下打开project.json文件,修改:

    "modules" : ["cocos2d", "extensions", "external"],

    2、加载

    var CocoStudio_index = "res/cocostudio导出的文件夹/JSON文件.json"; 
     
    var res = { 
        HelloWorld_png : "res/HelloWorld.png", 
        CloseNormal_png : "res/CloseNormal.png", 
        CloseSelected_png : "res/CloseSelected.png", 
    }; 
     
    var g_resources = [ 
        //image 
        res.HelloWorld_png, 
        res.CloseNormal_png, 
        res.CloseSelected_png, 
        //json 
        CocoStudio_index, 
    ]; 
    cc.game.onStart = function(){ 
        cc.view.setDesignResolutionSize(640, 960, cc.ResolutionPolicy.SHOW_ALL); 
    cc.view.resizeWithBrowserSize(true); 
        //load resources 
        cc.LoaderScene.preload(g_resources, function () { 
            cc.director.runScene(new HelloWorldScene()); 
        }, this); 
    }; 
    cc.game.run();

    3、程序中使用

    var root = ccs.uiReader.widgetFromJsonFile(CocoStudio_index);
    this.addChild(root,100);
  • 相关阅读:
    Android AdapterView View的复用机制 分析
    go12---interface
    go11---方法method
    go10---struct
    go09---defer
    go8---函数function
    go7---map
    go6---slice切片
    go5--数组
    go4--break,continue + 标签
  • 原文地址:https://www.cnblogs.com/linn/p/3644679.html
Copyright © 2020-2023  润新知