0

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

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81

1 Answers1

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.

olsn
  • 16,644
  • 6
  • 59
  • 65
  • Thanks for the tip, I am using hitTest but it doesn't seem to work as expected. I have a Square container with a 50x50 square within it at x=50 and y=50. When I click it and do the hit test it returns false, but when I click x=0 y=0 the hit test returns true – Cjmarkham Aug 16 '13 at 12:35
  • the hit test is being ran on the containers children – Cjmarkham Aug 16 '13 at 12:35
  • as I mentioned, you will have to translate the coordinates to each of the childrens local coordinate space, in your case that depends on where the listener is from: `localCoords = listenerObject.localToLocal(x,y,targetChild);` - that should do it – olsn Aug 16 '13 at 12:46
  • I have used hit test and it worked fine on a solid block, but when I use a triangle for instance, only the opaque parts are registered with hitTest, not the fully transparent parts. – Cjmarkham Aug 16 '13 at 14:05
  • Yes that is correct, but it ignores the alpha value of the display-object – olsn Aug 16 '13 at 16:17