我们可以在构造函数中添加触摸:
//在事件管理器中添加监听;
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");
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。