var Touchlistener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
onTouchBegan: function (touch, event) {
var target = event.getCurrentTarget();
var locationInNode = target.convertToNodeSpace(touch.getLocation());
var s = target.getContentSize();
var rect = cc.rect(0, 0, s.width, s.height);
if (cc.rectContainsPoint(rect, locationInNode)) {
return true;
}
return false;
},
onTouchMoved: function (touch, event) {
var target = event.getCurrentTarget();
var delta = touch.getDelta();
target.x += delta.x;
target.y += delta.y;
if(target.x<0){
target.x=0;
}else if(target.x>1920){
target.x=1920;
}
if(target.y<0){
target.y=0;
}else if(target.y>1080){
target.y=1080;
}
},
onTouchEnded: function (touch, event) {
var target = event.getCurrentTarget();
var lidhit = lid_png.getBoundingBox();
// var funchinebt_pnghit = funchinebt_png.getBoundingBox();
if (cc.rectIntersectsRect(lidhit, alum_pnghit)) {
cc.log("1");
hitcap = false;
} else {
hitcap = true;
cc.log("2");
}
}
}
});
cc.eventManager.addListener(Touchlistener,lid_png);
点击查看更多内容
3人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦