Skip to content

Container

何波 edited this page Feb 14, 2019 · 12 revisions

Container.getObjectsUnderPoint ( x y [mode=0] ) Array

返回此Container中指定坐标(x,y)下所有DisplayObject的数组。如果该Container中的DisplayObject设置mouseEnabled = true将会忽略。数组将按可视深度的顺序排序,最上面的DisplayObject索引为0。这是用最基础的形状检查,并且运行起来可能是一个昂贵的操作,所以你最好小心使用它。例如,if testing for objects under the mouse, test on tick (instead of on stagemousemove), and only if the mouse's position has changed.

  • 默认情况下(mode=0),此方法计算所有显示对象DisplayObject。
  • mode=1,将遵守mouseEnabled和mouseChildren属性值。
  • mode=2,会排除DisplayObject没有mouse event listeners 或DisplayObject:Cursor:Property属性的显示对象。也就是说,只包括通常会拦截鼠标交互的对象。在某些情况下,这可以通过减少需要测试的显示对象的数量来显著提高性能。

这个方法同时解释了hitarea和mask。

Clone this wiki locally