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

查看:147
本文介绍了如何在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的 Canvas Performance Tutorial

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天全站免登陆