cocos2d-js 使用 cocos studio创建的资源:
目录:
资源文件:
cocos studio:
最后在浏览器中的运行效果:
代码:
cc.log("scene is begin"); var mainscene = ccs.load(res.MainScene_json); this.addChild(mainscene.node); var btn = ccui.helper.seekWidgetByName(mainscene.node,"Button_1"); btn.addTouchEventListener(this.selectedStateEvent,this); cc.log("scene is over");
selectedStateEvent:function(sender,type){ switch(type){ case ccui.Widget.TOUCH_BEGAN: cc.log("touch begin"); break; case ccui.Widget.TOUCH_MOVED: cc.log("touch moved"); break; case ccui.Widget.TOUCH_ENDED: cc.log("touch end"); break; case ccui.Widget.TOUCH_CANCELED: cc.log("touch cancle"); break; default: break; } }原文链接:https://www.f2er.com/cocos2dx/342304.html