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

 

 

 

posted on 2014-04-04 10:46  凌度  阅读(2815)  评论(0编辑  收藏  举报