[带有EaselJS的透明矩形上的单击事件

问题描述 投票:6回答:1

是否可以使透明矩形可点击?我不想填充它,所以它看起来像

     shape.graphics.setStrokeStyle(2).beginStroke("#000").rect(0, 0, 100, 100)
easeljs
1个回答
13
投票

这是我如何执行的代码:

var shape = new createjs.Shape();    
shape.graphics.setStrokeStyle(2).beginStroke("#000").rect(0, 0, 100, 100);
var hit = new createjs.Shape();
hit.graphics.beginFill("#000").rect(0, 0, 100, 100);
shape.hitArea = hit;

0
投票

只需编辑Misha的答案。由于形状需要具有填充色才能起作用,因此设置hit.visible = false将起到透明度的作用。

© www.soinside.com 2019 - 2024. All rights reserved.