//在事件管理器中添加监听;
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");
}
原文链接:https://www.f2er.com/cocos2dx/345345.html