【cocos2dx-js 学习分享 五】 触摸相应机制

【cocos2dx-js 学习分享 五】 触摸相应机制,第1张

概述我们可以在构造函数中添加触摸:   //在事件管理器中添加监听; cc.eventManager.addListener({   //规定事件监听为 ONE_BY_ONE event  : cc.EventListener.TOUCH_ONE_BY_ONE,   //允许触摸传递 swallowTouches  :  true,   //触摸开始onTouchBegan onTouchBegan 

我们可以在构造函数中添加触摸:

//在事件管理器中添加监听;

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");

}

总结

以上是内存溢出为你收集整理的【cocos2dx-js 学习分享 五】 触摸相应机制全部内容,希望文章能够帮你解决【cocos2dx-js 学习分享 五】 触摸相应机制所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1024918.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存