标签:
我们可以在构造函数中添加触摸:
//在事件管理器中添加监听;
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");
}
标签:
原文地址:http://blog.csdn.net/u010296979/article/details/42101025