问题
I need to get all bitmaps under point in a container. The bitmaps alpha is set to 0 and this doesnt seem to work with this method.
Are there any alternatives? I cant just add an event listener to the object as that is not enough in this scenario.
Thanks
回答1:
1) If you just want to get the objects under a point you'd have to loop through all children of the container and call hitTest(x,y)
(http://www.createjs.com/Docs/EaselJS/classes/DisplayObject.html#method_hitTest) this ignores the alpha-value. (remember to call the method with the coordinates in the object's local coordinate space)
2) If you want to work with EventListeners and Alpha-0 objects, you can define another DisplayObject as the hitArea
(http://www.createjs.com/Docs/EaselJS/classes/DisplayObject.html#property_hitArea) - in that case only the shape, alpha, ect.. of the hitArea object is used.
来源:https://stackoverflow.com/questions/18272286/createjs-getobjectsunderpoint-when-alpha-0