AS2:没有影片剪辑的热门歌曲?

发布于 2024-11-19 22:35:31 字数 229 浏览 9 评论 0原文

我在舞台上有数千个简单的影片剪辑(矩形),它们正在与另一个矩形进行碰撞测试,问题是我现在有太多的影片剪辑,导致我的 SWF 播放有些断断续续。

我不能没有这些 MC,所以有人知道一种纯粹针对绘制向量进行 hitTest 的方法吗? (向量由动作脚本绘制)。我也尝试将它们缓存为位图,但它们是非常小的矩形,并且在位图时显得非常不稳定和难看。

如果将所有矩形视为一个 MC 并分别对每个矩形进行命中测试,那就太好了。

I have thousands of simple movieclips on the stage (rectangles), that are being hittested against another rectangle, the problem is I now have so many movieclips it is causing my SWF to playback somewhat choppy.

I cannot do without these MCs, so does anyone know of a way to hitTest purely against the drawn vectors? (The vectors are drawn by actionscript). I have also tried to cache these as bitmap but they are very small rectangles and appear very choppy and ugly when bitmapped.

It would be nice to just treat all the rectangles as one MC and hittest for each individually.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惯饮孤独 2024-11-26 22:35:31

hitTest 方法本身需要大量计算,这就是为什么在处理数千次碰撞时,您需要最小化该方法的使用或实现自己的碰撞检测方法。

Sham Bhangal 所著的“Flash Hacks”一书(O'Reilly 2004)描述了检测多重碰撞的简单方法。该方法的核心思想是将所有影片剪辑添加到一个容器影片剪辑中,然后测试该容器影片剪辑与点(或对象)的碰撞。您可以在网络上搜索此黑客攻击的重印本。

如果该方法不适合您,那么您可能需要处理矩形碰撞检测技术(并摆脱 hitTest)。您可以阅读这篇文章,它展示了检测轴对齐边界框之间碰撞的方法,或AABB等物体。定向边界框(OBB)之间的碰撞检测更为复杂,但您可以找到并修改现有算法。我在此 OBB 碰撞检测演示<中使用了上面链接中的算法< /a>.我已经包含了它的源代码(AS3 不是 AS2),所以你也可以检查一下。

hitTest method itself requires a lot of calculation, that's why when dealing with thousands of collisions you need to minimize the usage of that method or implement your own method for collision detection.

Easy way to detect multiple collisions was described at the book "Flash Hacks" by Sham Bhangal (O'Reilly 2004). The core idea of that method was to add all the movieClips into one container movieClip and then test the collision of that container movieClip with the point (or object). You may search for reprints of this hack on the web.

If that method doesn't suite you, then probably you'll need to deal with rectangle collision detection techniques (and get rid of hitTest). You may read this article which shows the ways to detect collision between axis-aligned bounding box, or AABB and other objects. The detection of collision between oriented bounding boxes, or OBB, is more complex, but you may find and modify existing algorithms. I've used the algorithm from the link above in this OBB collsion detection demo. I've included the source code of it (AS3 not AS2), so you may check that out also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文