Cocosd2d-js 使用Cocos Studio生成的Json界面文件

来源:互联网 发布:入门单反推荐2017知乎 编辑:程序博客网 时间:2024/04/26 09:14

使用Cocos Studio生成界面文件,用Js进行加载,将生成Json文件和图片素材放在res目录下,比如登陆界面的LoginScene.json文件加载如下:

        var UIroot = ccs.load(game.resources["LoginScene_json"]).node;        UIroot.setAnchorPoint(cc.p(0.5,0.5));        UIroot.setPosition(size.width/2,size.height/2);        this.addChild(UIroot, 0);        var accountEdit = ccui.helper.seekWidgetByName(UIroot, "UserInput");        accountEdit.setPlaceHolder("Input account");        accountEdit.addEventListener(this.textFieldEvent.bind(this),this);        accountEdit.setName("account");        //accountEdit.setDelegate(this);        var passEdit = ccui.helper.seekWidgetByName(UIroot, "PassInput");        passEdit.setPlaceHolder("Input password");        passEdit.addEventListener(this.textFieldEvent.bind(this),this);        passEdit.setName("password");        //passEdit.setDelegate(this);        var closeBtn = ccui.helper.seekWidgetByName(UIroot, "CloseBtn");        // closeBtn.setEnabled(false);        closeBtn.addClickEventListener(this.onTest.bind(this));        closeBtn.setBright(true);        closeBtn.setTouchEnabled(true);        closeBtn.setEnabled(true);        var loginBtn = ccui.helper.seekWidgetByName(UIroot, "LoginBtn");        loginBtn.addClickEventListener(this.onLogin.bind(this));        var registBtn = ccui.helper.seekWidgetByName(UIroot, "RegistBtn");        registBtn.addClickEventListener(this.onRegister.bind(this));        var oneKeyBtn = ccui.helper.seekWidgetByName(UIroot, "OneKeyBtn");        oneKeyBtn.addClickEventListener(this.onSingleLogin.bind(this));

0 0
原创粉丝点击