如何在 HTML5 中提高游戏中许多对象的性能? [英] How to improve performance with many objects in game in HTML5?

查看:29
本文介绍了如何在 HTML5 中提高游戏中许多对象的性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当需要显示许多对象并计算位置、碰撞检测、反应等并且我希望一切看起来顺利时,我可以做什么?这是我正在开发的 示例.我希望如果屏幕上有 100 个球,我可以流畅地显示它们.但我不知道该怎么做.我们将不胜感激每一个建议.

What things can I do when it's necessary to show many objects and calculate position, collision detection, reaction, etc. and I want everything look smoothly? Here's an example I'm developing. I want that if I have 100 balls on the screen, I can show them smoothly. But I don't have any idea of how to do it. Every suggestion will be appreciated.

推荐答案

在这个 HTML5 Rock 的 画布性能教程.

The basic steps to improve performance in canvas can be seen in this HTML5 Rock's Canvas Performance Tutorial.

而且,如果您可以在没有 Box2D 的情况下自由处理碰撞检测,请查看此 四叉树实现.四叉树不直接处理冲突,但可以通过减少检测冲突所需的比较量来提高性能.

And, if you are free to handle collision detection without Box2D, check this quad-tree implementation. The quad-tree doesn't deals with collisions directly but can improve performance by reducing the amount of comparisons needed to detect the collisions.

文章推荐阅读:

使用空间分区的广泛相位碰撞检测

碰撞检测和响应

使用 Box2dWeb 制作游戏

这篇关于如何在 HTML5 中提高游戏中许多对象的性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆