心好累。本来自己写的view处理过拖动 后来才发现有dialog想用 结果并不能满足自己需求。于是最后发现了还不如自己处理相关的部分。
核心就是如下方法:
public setCanDrag(canDrag:boolean)
{
this.m_CanDrag = canDrag;
if(this.m_CanDrag)
{
this.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
}
else
{
this.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
}
}
onMouseDown(e: Laya.Event)
{
// console.log(e.currentTarget, e.target);
if(e.target == this)
{
this.startDrag();
}
else
{
this.stopDrag();
}
}
判断一下点击对象是否是自己。才处理拖动。