我应该使用哪个 Box2D JavaScript 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7628078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 02:57:43  来源:igfitidea点击:

Which Box2D JavaScript library should I use?

javascriptbox2d

提问by a paid nerd

There are a few different ports of Box2Dfor JavaScript. Which one is the best?

有几个不同的用于 JavaScript的Box2D端口。哪一个是最好的?

  • Box2DJS- "converted from Box2DFlashAS3_1.4.3.1 in an automatic manner"

  • Box2Dflash 2.0 ported to JavaScript- "one big nasty hack that just happens to work"

  • box2dweb- "a port of Box2DFlash 2.1a to JavaScript. I developed an ActionScript 3 -to- JavaScript converter to generate the code"

  • HBehrens/box2d.js- "a JavaScript Version of Box2D 2.1a" (Added Nov 21, 2011)

  • kripken/box2d.js- "a direct port of the Box2D 2D physics engine to JavaScript, using Emscripten" (Added Sep 24, 2013)

  • Box2DJS- “以自动方式从 Box2DFlashAS3_1.4.3.1 转换而来”

  • Box2Dflash 2.0 移植到 JavaScript- “一个刚好工作的大讨厌黑客”

  • box2dweb- “Box2DFlash 2.1a 到 JavaScript 的端口。我开发了一个 ActionScript 3 到 JavaScript 转换器来生成代码”

  • HBehrens/box2d.js- “Box2D 2.1a 的 JavaScript 版本”(2011 年 11 月 21 日添加)

  • kripken/box2d.js- “Box2D 2D 物理引擎到 JavaScript 的直接端口,使用 Emscripten”(2013 年 9 月 24 日添加)

Any ideas which version http://chrome.angrybirds.com/uses, if any?

http://chrome.angrybirds.com/使用哪个版本的任何想法,如果有的话?

采纳答案by a paid nerd

Note to readers!

This question was originally asked and answered in 2011, but I'll do my best to keep it up to date!

读者注意!

这个问题最初是在 2011 年提出并回答的,但我会尽力使其保持最新状态!

Here's what I've found:

这是我发现的:

  • kripken/box2d.jsis a port of Box2D using Emscripten and works well and is fast. I have used this personally with great success.
  • planck.jsis the newest port and is written from the ground-up in JavaScript
  • Box2DJS is a port of Box2DFlash 1.4.3.1. box2dweb is a port of version 2.1a.
  • Box2DJS works "as a CommonJS module without any modifications at all" [1]
  • Box2DJS "not up-to-date and you have to import a big amount of JavaScript files in every project" [2]
  • box2dweb is contained in a single file [2]
  • box2dweb is "a much newer port and has a lot fewer issues" than Box2DJS [3]. However, switching might introduce new issues [4].
  • Box2DJS depends on Prototype but box2dweb does not [5]
  • Seth Ladd has promoted box2dweb with examples on his blog [6]
  • Nobody seems to be using the third alternative.
  • There are also physics simulators notbased on Box2D. Check out Matter.jsand p2.js
  • kripken/box2d.js是使用 Emscripten 的 Box2D 端口,运行良好且速度快。我个人使用它并取得了巨大成功。
  • planck.js是最新的端口,是用 JavaScript 从头开始​​编写的
  • Box2DJS 是 Box2DFlash 1.4.3.1 的一个端口。box2dweb 是 2.1a 版的一个端口。
  • Box2DJS “作为一个 CommonJS 模块,完全没有任何修改” [1]
  • Box2DJS“不是最新的,你必须在每个项目中导入大量的 JavaScript 文件” [2]
  • box2dweb 包含在单个文件中[2]
  • box2dweb 与 Box2DJS [3]相比,是“一个更新得多的端口,问题也少得多” 。但是,切换可能会引入新问题[4]
  • Box2DJS 依赖于 Prototype 但 box2dweb 不依赖[5]
  • 赛斯·拉德 (Seth Ladd) 在他的博客[6]上用示例推广了 box2dweb
  • 似乎没有人在使用第三种选择。
  • 还有一些不是基于 Box2D 的物理模拟器。查看Matter.jsp2.js

There's also a similar discussion on gamedev.stackexchange.com.

在 gamedev.stackexchange.com上也有类似的讨论

I'd say that the winner is kripken/box2d.js.

我想说获胜者是 kripken/box2d.js。

回答by Nelson

This question and its best answer are from 2011. One recent new option is box2.js, an Emscripten translation of the C++ code to Javascript. As of August 2013 it's more up-to-date than the other ports I've found, and the demos seem to work.

这个问题及其最佳答案来自 2011 年。最近的一个新选项是box2.js,它是从C++ 代码到 Javascript 的 Emscripten 翻译。截至 2013 年 8 月,它比我发现的其他端口更新,并且演示似乎有效。

回答by DylanVann

LiquidFun (With JS Bindings)

LiquidFun(带有 JS 绑定)

LiquidFun is, at the time I'm posting this, the most recent port to JS. It has all the features of Box2D and liquid physics features. It's ported using emscripten, so performance is decent.

LiquidFun 是,在我发布这篇文章的时候,最新的 JS 端口。它具有 Box2D 的所有功能和液体物理功能。它是使用 emscripten 移植的,因此性能不错。

google/liquidfun

谷歌/ Liquidfun

google/liquidfun/tree/master/liquidfun/Box2D/lfjs

谷歌/liquidfun/tree/master/liquidfun/Box2D/lfjs

回答by zoosrc

Probably the best place to keep up to date with Box2D JavaScript ports is the official forum: http://box2d.org/forum/viewforum.php?f=22

可能与 Box2D JavaScript 端口保持同步的最佳地点是官方论坛:http: //box2d.org/forum/viewforum.php?f=22

JSBox2Dlooks like a good start.

JSBox2D看起来是一个好的开始。

I would definitely have a look into Matter.js, which seems very well built and very quick. I'm going down this path. http://brm.io/matter-js

我肯定会看看Matter.js,它看起来非常好而且非常快。我要走这条路。http://brm.io/matter-js

回答by cuixiping

Box2d-html5is also another box2d port including Google's LiquidFun) and active update.

Box2d-html5也是另一个box2d端口,包括 Google 的LiquidFun)和主动更新。

回答by Vennsoh

Box2DWeb supports most of the API from the original C++ Box2D except chain shapes. :/

Box2DWeb 支持原始 C++ Box2D 中的大部分 API,除了链形状。:/

It is the most widely used Javascript Box2D. If you need the API documentation for Box2DWeb, check out Box2DFlash. http://www.box2dflash.org/docs/2.1a/reference/

它是使用最广泛的 Javascript Box2D。如果您需要 Box2DWeb 的 API 文档,请查看 Box2DFlash。http://www.box2dflash.org/docs/2.1a/reference/

Box2DWeb is auto generated from Box2DFlash using a compiler. So the API is the same.

Box2DWeb 是使用编译器从 Box2DFlash 自动生成的。所以API是一样的。

I doubt Box2DWeb will get any update in the future anymore as Box2DFlash has shown no activities anymore. You can see the author's rational on why he decided not to write a direct Box2D --> Box2DWeb port.

我怀疑 Box2DWeb 将来会得到任何更新,因为 Box2DFlash 不再显示任何活动。您可以看到作者为什么决定不直接编写 Box2D --> Box2DWeb 端口的理性。

https://code.google.com/p/box2dweb/wiki/Roadmap

https://code.google.com/p/box2dweb/wiki/Roadmap