ActionScript - 在运行时光栅化矢量图形?
我开发了一个跨平台 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您说您尝试对位图进行动画处理时,我希望您并不是在旋转/调整位图大小 - 因为这是一个缓慢的过程。
也许有一个引擎,当您的游戏加载时,它会根据 MovieClip 中的帧(如果有动画)为您创建一个精灵表。然后这些可以被 BitmapData.copyPixels() 引用。
这很简单:
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:
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..?