Cocos-JS 加载Cocos Studio文件获取按钮实现

Cocos-JS 加载Cocos Studio文件获取按钮实现,第1张

概述Cocos Studio中添加按钮 app.js var HelloWorldLayer = cc.Layer.extend({ sprite: null, ctor: function () { ////////////////////////////// // 1. super init first this._super();

Cocos Studio中添加按钮


app.Js

var HelloWorldLayer = cc.Layer.extend({    sprite: null,    ctor: function () {        //////////////////////////////        // 1. super init first        this._super();        /////////////////////////////        // 2. add a menu item with "X" image,which is clicked to quit the program        //    you may modify it.        // ask the window size        var size = cc.winSize;        // 加载Cocos Studio资源        var mainscene = ccs.load(res.MainScene_Json);        this.addChild(mainscene.node);        var startbutton = ccui.helper.seekWidgetByname(mainscene.node,"button_1");        startbutton.addtouchEventListener(this.onClick,this);        return true;    },    onClick: function (sender,type) {        switch (type) {            case ccui.Widget.touch_BEGAN:                break;            case ccui.Widget.touch_MOVED:                break;            case ccui.Widget.touch_ENDED:                console.log("startbuttonOnClick");                cc.director.runScene(new GameScene);
              break;
case ccui. Widget. touch_CANCELED: break ; } }}) ; var HelloWorldScene = cc. Scene. extend({ onEnter: function () { this. _super() ; var layer = new HelloWorldLayer() ; this. addChild(layer) ; }}) ; 总结

以上是内存溢出为你收集整理的Cocos-JS 加载Cocos Studio文件获取按钮实现全部内容,希望文章能够帮你解决Cocos-JS 加载Cocos Studio文件获取按钮实现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1085675.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存