var listener=cc.EventListener.create({
event:cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches:true,
onTouchBegan:function(touch,event){
if(that.reachTarget)return false; //到达位置后不能移动
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)){
target.setZOrder(10);
return true;
}
return false;
},
onTouchMoved:function(touch,event){
var target=event.getCurrentTarget();
var delta=touch.getDelta();
target.x+=delta.x;
target.y+=delta.y;
},
cocos实现按钮多种状态监听
最新推荐文章于 2022-05-03 11:08:51 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)