Actionscript3/flash cs4:如何解决从浏览器启动时的滞后问题

发布于 2024-11-29 13:19:46 字数 697 浏览 1 评论 0 原文

我已经在 Flash 游戏上工作了一个月,该游戏应该可以在浏览器中玩(轻计算)。话虽这么说,我注意到在某些浏览器中游戏的运行速度看起来像是 15 fps(游戏应该以 80 fps 运行)。众所周知,这种情况在 IE9 中会发生,快速修复方法是将这一行添加到 html 的顶部:

<meta http-equiv="X-UA-Compatible" value="IE=9">

这是一个快速修复方法,强制 IE 进入兼容模式并大大提高了 fps(到大约... 60,这么说吧)。

尽管如此,我相信游戏在每个浏览器中的运行速度都比应有的要慢,这一点在将 html 版本与 swf 进行比较时显而易见。

游戏 (html) 中的运动“倾斜”也是相当明显的:这些倾斜损害了游戏的美感,从而损害了可玩性!

所有这些让我相信浏览器限制了对计算机显卡的访问;

1) html 很慢,swf 很快

2) 声音以正常速度播放,但图形滞后

编辑

3) 游戏中的所有图形分辨率都相当低(即游戏中显示的图形)因为 width1xheight1 是 width1xheight1 png 的动画片段)+尽可能小

4)我制作了非常(计算上)简单的 Flash 项目,并看到了相同的图形移动问题。

谁能给我一些关于如何提高浏览器中游戏流畅度的建议?

I've been working for a month on a flash game, which should be manageable to play in a browser (light computation). This being said, I've noticed that in some browsers the game runs at what looks like 15 fps (the game should run in 80fps). This has been known to happen in IE9, and the quick fix was to add this line to the top of the html:

<meta http-equiv="X-UA-Compatible" value="IE=9">

This was a quick-fix that forces IE into compatibility mode and greatly improved the fps (to about... 60, let's say).

Still, I believe that the game is running slower than it should in every browser, which is evident when the html version is compared to the swf.

It's also fairly noticeable that the movement in the game (html) "lurches": these lurches injure the aesthetics of the game, and therefore the playability!

All of this leads me to believe that browsers limit access to computers' graphics card;

1) It's slow in html, and fast in swf

2) Sounds play at normal speed, yet graphics lag

EDIT

3) All the graphics in the game are fairly low resolution (i.e., graphics that are displayed ingame as width1xheight1 are movieclips of width1xheight1 png's) + as minimal as possible

4) I've made very (computationally) simple flash projects and seen the same graphic-movement problems.

Can anyone give me some advice as to how I can increase the smoothness of my game in browsers?

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

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

发布评论

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

评论(1

风蛊 2024-12-06 13:19:46

这可能是 SWF 如何嵌入 HTML 页面的症状。 Flash 支持多种“窗口模式”,这些模式决定了内容如何呈现到浏览器窗口中。当 SWF 嵌入到 HTML 页面中时,这是通过 wmode 参数设置的。

根据 Adobe 文档,应将其设置为“direct”以获得最佳性能:

direct - 使用直接路径渲染。这绕过了合成
屏幕缓冲区并将 SWF 内容直接呈现到屏幕上。
建议使用此 wmode 值以提供最佳性能
内容播放并启用 SWF 的硬件加速呈现
使用 Stage Video 或 Stage 3D 的内容。

实际上,wmode 的行为可能不稳定,因此尝试 文档

其他可能有助于提高性能的选项包括:

  • 使用stage.scaleMode = StageScaleMode.NO_SCALE。如果嵌入的尺寸与原始尺寸不匹配,这将防止内容被缩放。缩放会增加 CPU 使用率,因此禁用它会增加帧速率(请参阅 StageScaleMode#NO_SCALE)。
  • 在非透明影片剪辑(例如根影片剪辑)上设置 opaqueBackground。透明度需要额外的计算来将前景色与背景色相乘。设置不透明背景会绕过这些额外的计算,并可能会导致性能提升。 (请参阅 DisplayObject#opaqueBackground

This could be a symptom of how the SWF is embedded in the HTML page. Flash supports a number of "window modes" which determine how the content is rendered into the browser window. This is set via the wmode parameter when the SWF is embedded in the HTML page.

According to Adobe's documentation, this should be set to "direct" for best performance:

direct - Use direct to path rendering. This bypasses compositing in
the screen buffer and renders the SWF content directly to the screen.
This wmode value is recommended to provide the best performance for
content playback and enables hardware accelerated presentation of SWF
content that uses Stage Video or Stage 3D.

In practice, the wmode can act erratically so it may help to try the alternatives mentioned in the documentation.

Other options which may help improve performance are:

  • Use stage.scaleMode = StageScaleMode.NO_SCALE. This will prevent content from being scaled should the embedded size not match the original size. Scaling contributes to CPU usage so disabling it should increase the frame-rate (see StageScaleMode#NO_SCALE).
  • Set opaqueBackground on non-transparent MovieClips (such as the root MovieClip). Transparency requires extra calculations to multiply the foreground color with the background color. Setting an opaque background bypasses these additional calculations and may result in a performance boost. (see DisplayObject#opaqueBackground)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文