Draggable 组件
启用实体拖放。监听来自 MouseDrag
的实体移动相关事件。
方法
Back to top
.dragDirection()
用于修改拖动方向的方法。如果设置了方向,被拖动的实体只会沿着指定的方向移动。如果没有设置方向,则被拖动的实体将沿着任何方向移动。
public this .dragDirection()
删除之前指定的方向。
public this .dragDirection(vector)
- vector
形式为 {x: valx, y: valy}, vector (valx, valy) 表示移动的方向。
public this .dragDirection(degree)
- degree
一个数字, 移动方向相对于x轴的度数(顺时针方向)。
指定拖动方向。
例子
this.dragDirection()
this.dragDirection({x:1, y:0}) //Horizontal
this.dragDirection({x:0, y:1}) //Vertical
// Note: because of the orientation of x and y axis,
// this is 45 degree clockwise with respect to the x axis.
this.dragDirection({x:1, y:1}) //45 degree.
this.dragDirection(60) //60 degree.