听Click事件上重叠精灵 [英] Listen to click event on overlapped sprites

查看:146
本文介绍了听Click事件上重叠精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个精灵在我的影片剪辑,一是在另一方面,我希望同时听鼠标点击事件。 我发现,只有顶层精灵接收到该事件时,我一下就可以了。 我需要派遣两个事件,所以我不能使用的mouseEnabled =虚假的。

I have two sprites in my movieclip, one under the other, and i want both to listen to mouse clicks event. I found that only the top level sprite receives the event when i click on it. I need to dispatch the events on both, so I can't use mouseenabled=false.

有一个简单的解决方法吗?

Is there a simple workaround for this?

推荐答案

您可以使用 getObjectsUnderPoint 的方法,原产于的DisplayObjectContainer

You can use the 'getObjectsUnderPoint' method native to the DisplayObjectContainer

您可以看到它在这里工作:

You can see how it works here:

http://snipplr.com/view/34945/as3 -trace-影片剪辑-下鼠标/

和这里的AS3参考: <一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html

and the AS3 reference here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html

您会听在舞台上的任何点击事件,如果之一发生时,请检查您所需要的元素是根据该点击位置。

You would listen on the stage for any click event and if one occurs, check to see if the element you require is under that click position.

这篇关于听Click事件上重叠精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆