4 javascript drag-and-drop easeljs
我试图实现类似于下面的代码.当用户位于矩形的边缘时,光标指向指针,否则光标是箭头.
shape.graphics.beginStroke("#000").beginFill("#daa").drawRect(50, 150, 250, 250);
shape.on("mousemove", function(evt) {
if (isOnEdges(evt)) {
evt.target.cursor = "pointer";
} else {
evt.target.cursor = "arrow";
}
});
Run Code Online (Sandbox Code Playgroud)
上述代码的问题是:
Lan*_*nny 10
您只需将光标设置在形状上,并确保在舞台上启用了EnableMouseOver:
var shape = new Shape();
shape.graphics.beginStroke("#000").beginFill("#daa").drawRect(50, 150, 250, 250);
shape.cursor = "pointer";
stage.enableMouseOver();
Run Code Online (Sandbox Code Playgroud)
EaselJS将自动确定何时超出形状的界限.