当坐标'y'在像素'y-15'上,在特定坐标(x,y)上时,我必须为圆的移动设置一个限制。我尝试将 'draggable=true' 与事件 'mouseup' 和 'mousedown' 一起使用,但我无法获得所需的结果。有人能帮助我吗?
我的代码是:
circle.on('mouseover',function(){
this.setAttr('draggable',true);
});
circle.on('dragmove',function(e){
var mousePos = stage.getMousePosition();
var x = mousePos.x;
var y = mousePos.y;
if(y < y2- 15){
//do anything
}
else{
this.setAttr('draggable',false);
}
});