ActionScript - 在运行时光栅化矢量图形?

发布于 2024-11-09 02:13:38 字数 369 浏览 0 评论 0原文

我开发了一个跨平台 AIR 应用程序,由于动画/使用矢量图形而不是位图资源,该应用程序在移动设备上的性能严重下降。在适当分配的时间和地点,使用cacheAsBitmapMatrix/cacheAsBitmap会更好,但仍然不如使用位图资源那么快。

我尝试在运行时将矢量图形 bitmapData.draw() 转换为 Bitmap 对象,并对位图对象进行动画处理,但这仅执行大约(甚至可能完全相同)简单地将矢量图形缓存为位图。

Flash Professional 5.5 UI 现在能够将矢量图形转换为位图资源,但是否可以在运行时执行此操作?是否有可能有一个实际的 Rasterize() 例程来在运行时将编程绘制的矢量图形甚至可编辑文本转换为位图以获得最佳动画性能,尤其是在移动设备上?

i've developed an cross-platform AIR application, which seriously under performs on mobile devices caused by animating/using vector graphics instead of bitmap assets. employing cacheAsBitmapMatrix / cacheAsBitmap is better, when and where assigned appropriately, but still not as fast as using bitmap assets.

i've attempted to bitmapData.draw() the vector graphics to a Bitmap object at runtime and animate the bitmap object instead, but this performs only about as well as (or maybe even exactly the same as) simply caching the vector graphic as a bitmap.

Flash Professional 5.5 UI now has the ability to convert a vector graphic into a bitmap assets, but is it possible to do this at runtime? is it possible to have an actual Rasterize() routine to convert programatically drawn vector graphics and maybe even editable text into bitmaps at runtime for optimal animated performance, especially on mobile devices?

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

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

发布评论

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

评论(1

感情洁癖 2024-11-16 02:13:38

当您说您尝试对位图进行动画处理时,我希望您并不是在旋转/调整位图大小 - 因为这是一个缓慢的过程。

也许有一个引擎,当您的游戏加载时,它会根据 MovieClip 中的帧(如果有动画)为您创建一个精灵表。然后这些可以被 BitmapData.copyPixels() 引用。

这很简单:

  1. 创建一个 BitmapData 对象。
  2. 将 MovieClips 时间线的每一帧绘制到 BitmapData 上,就像使用 sprite 表手动绘制一样。
  3. 将 BitmapData 存储到关联数组中以便稍后访问,例如 sheets["zombie1"]

您甚至可以在 for 循环中旋转对象并将旋转后的对象绘制到工作表上。

然后,您的 SheetObject 将仅具有用于加载先前定义的工作表的一部分并显示它的方法。

这一切都在正确的轨道上吗?

When you say that you tried animating the bitmap, I hope you didn't mean that you were rotating/resizing the bitmap - as that's a slow process.

Maybe have an engine that while your game is loading, creates a sprite sheet for you based on the frames in a MovieClip (if there's animation). Then these could be referenced by BitmapData.copyPixels().

This would simply:

  1. Create a BitmapData object.
  2. Draw each frame of the MovieClips timeline onto the BitmapData as you would manually with a sprite sheet.
  3. Store the BitmapData into an associative array for easy access later on, eg sheets["zombie1"]

You could even rotate your object in a for loop and draw the rotated object onto the sheet.

Then your SheetObject would just have methods for loading a portion of a previously defined sheet and displaying it.

Is this all on the right track..?

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