AS3:命中测试任何对象
我正在开发一个以图像作为光标的应用程序。现在我想随时知道光标悬停在哪个对象上。有点像 HitTestObject(*),然后我可以看到 * 代表什么对象。有谁知道我如何才能做到这一点? (并且不能使用鼠标)
I am working on an application where an image serves as cursor. Now i would like to know at any time over which object the cursor is hovering. Sort of like a HitTestObject(*) where i can then see what object the * represents. Does anyone have any idea how i could accomplish this? (and using the mouse is not an option)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将要监视“悬停”的元素放在单独的数组中,
然后向附加到鼠标的对象添加一个 onEnterFrame 侦听器,该侦听器循环访问数组并对每个对象执行 hitTests。
这将出现在鼠标附加对象的 onEnterFrame 处理程序中:
Put the elements you want to monitor for 'hovering' in a separate array,
then add an onEnterFrame listener to the object attached to your mouse that iterates through the array and performs hitTests with each of the objects.
and this goes in the onEnterFrame handler for your mouse-attached object:
我已经解决了这个问题:)由于光标位于与其他精灵不同的精灵中,我必须这样做,因为我无法将对象传递到数组中。
I have solved the problem already :) since the cursor was in a different sprite than the others, i had to do it this way, because i couldn't pass the objects to hover into an array.