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);

 

 

 

你可能感兴趣的:(cocos2d-js)