拖动形状不填充 [英] drag shape without fill
问题描述
我正在尝试创建一个EaselJS应用,该应用可以让我在画布上拖动未填充的圆圈-因此在设置 beginFill
>形状我叫 beginStroke
。我遇到的问题是,如果我不填充形状,则只能在选择形状的左上角时拖动它。填充形状后,我可以通过选择形状中的任意位置来拖动它。有没有一种方法可以使未填充的形状与填充的形状相同?
I am trying to create an EaselJS app that lets me drag unfilled circles around the canvas - so instead of calling beginFill
when I am setting up the Shape
I would call beginStroke
. I am running into the problem that if I don't fill the shape, I can only drag it when I am selecting the top left corner of the shape. When the shape is filled I can drag it by selecting anywhere within the shape. Is there a way I can make the unfilled shape drag the same way as the filled shape?
推荐答案
在面具的EaselJS。但是,您可以将其他 Shape
分配为 hitArea
:
Strokes and fills are necessary in EaselJS for masks. You could however assign an other Shape
as hitArea
:
var shape = new createjs.Shape();
shape.graphics.beginFill("#000000").drawCircle(0, 0, 40);
draggableCircle.hitArea = shape;
请记住hitArea- Shape
不必添加到舞台上,因此不会显示。
Keep in mind that the hitArea-Shape
doesn't have to be added to the stage and thus won't be visible.
这篇关于拖动形状不填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!