CreateJS getObjectsUnderPoint when alpha = 0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:14:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!