/**************** // 添加鼠标事件监听器 var Listener = { event: cc.EventListener.MOUSE,onMouseDown: function (event) { cc.log('Mouse Down: ' + event); },onmouseup: function (event) { cc.log('Mouse Up: ' + event); },onMouseMove: function (event) { cc.log('Mouse Move: ' + event); },onMouseScroll: function (event) { cc.log('Mouse Scroll: ' + event); } } // 绑定鼠标事件 cc.eventManager.addListener(Listener,this.node);***************/ /********************** // 添加键盘事件监听器 var Listener = { event: cc.EventListener.KEYBOARD,onKeypressed: function (keyCode,event) { cc.log('keyDown: ' + keyCode); },onkeyreleased: function (keyCode,event) { cc.log('keyUp: ' + keyCode); } } // 绑定键盘事件 cc.eventManager.addListener(Listener,this.node);**********************/ /********************* // 添加单点触摸事件监听器 var Listener = { event: cc.EventListener.touch_ONE_BY_ONE,ontouchBegan: function (touches,event) { cc.log('touch Began: ' + event); return true; //这里必须要写 return true,//ontouchBegan 回调事件里要 return true, //这样后续的 ontouchended 和 ontouchmoved 才会触发事件 },ontouchmoved: function (touches,event) { cc.log('touch Moved: ' + event); },ontouchended: function (touches,event) { cc.log('touch Ended: ' + event); },ontouchCancelled: function (touches,event) { cc.log('touch Cancelled: ' + event); } } // 绑定单点触摸事件 cc.eventManager.addListener(Listener,this.node);**********************/ /****************** // 添加多点触摸事件监听器 var Listener = { event: cc.EventListener.touch_ALL_AT_ONCE,ontouchesBegan: function (touches,event) { // touches 触摸点的列表 cc.log('touch Began: ' + event); return true; //这里必须要写 return true },ontouchesMoved: function (touches,event) { cc.log('touch Moved: ' + event); },ontouchesEnded: function (touches,event) { cc.log('touch Ended: ' + event); },ontouchesCancelled: function (touches,event) { cc.log('touch Cancelled: ' + event); } } // 绑定多点触摸事件 cc.eventManager.addListener(Listener,this.node);*****************/总结
以上是内存溢出为你收集整理的cocos creator 事件集合全部内容,希望文章能够帮你解决cocos creator 事件集合所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)