本文介绍了动作3:获得在像素的显示对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何枚举像素相对于舞台下的显示对象?

How can I enumerate display objects under a pixel relative to the stage?

澄清:我想写这让(X,Y)作为输入,并返回一个数组对象作为输出的功能。

Clarification: I want to write a function which get (x,y) as input and returns an array of objects as output.

更新:我想避免遍历所有的显示对象,以分辨出哪一个是指定像素下

update: I want to avoid looping over all the display objects, to tell which one is under the specified pixel.

推荐答案

不限的DisplayObjectContainer(如MovieClip或阶段)具有一个称为getObjectsUnderPoint方法,返回显示对象根据该点的阵列。它采用Point对象作为参数。

Any DisplayObjectContainer (such as a MovieClip or the stage) has a method called getObjectsUnderPoint that returns an array of display objects under that point. It takes a Point object as an argument.

var myObjects: Array = stage.getObjectsUnderPoint(new Point(5, 5));

如果您使用的是它的一类,不要忘记导入flash.geom.Point;

If you are using it in a class don't forget to import flash.geom.Point;

这篇关于动作3:获得在像素的显示对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:38