【cocos2dx-js 学习分享 五】 触摸相应机制
我们可以在构造函数中添加触摸: //在事件管理器中添加监听; cc.eventManager.addListener({ //规定事件监听为 ONE_BY_ONE event : cc.EventListener.TOUCH_ONE_BY_ONE, //允许触摸传递 swallowTouches : true, //触摸开始onTouchBegan onTouchBegan : this.onTouchBegan, //触摸移动 onTouchMoved : this.onTouchMoved, //触摸结束 onTouchEnded : this.onTouchEnded },this); //以上为添加触摸事件,下面使用触摸事件 onTouchBegan :function(touch,event) { var touches =touch.getLocation(); if(touches){ cc.log("touches"); } }, onTouchMoved : function(touch,event) { cc.log("hello"); }, onTouchEnded :function(touch,event){ cc.log("world"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |