cocos creator 事件集合

前端之家收集整理的这篇文章主要介绍了cocos creator 事件集合前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
        /****************
        // 添加鼠标事件监听器
        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);*****************/
原文链接:https://www.f2er.com/cocos2dx/339292.html

猜你在找的Cocos2d-x相关文章