为四川人民祈祷! www.onefoundation.cn

box2d.js with jQuery

今天介绍 box2d.js 是 box2d 物理引擎的 js 版本, 美中不足的是它的开发是基于 prototype.js , 其实它只用了 prototype 的一些很少的功能. 对于熟悉 jQuery 的用户就大大的不爽. 于是我花了一些时间让 jQuery 用户也可以用上这个库.

原理很简单, 将 prototype.js 的 Class 模块保留下来, 写成一个 protoclass.js 文件给 box2d.js 使用. 这避免了加载 jQuery 的时候于 prototype 的冲突. 最后将 demo.js 中依赖 prototype 的 API 修改成基于 jQuery 的就可以了.

这是修改后的压缩包 box2d-js-jquery_0.1.0.zip
 
by kernel1983
Comments »
  1. Rob:
    2009-10-26 17:30
    Nice change, mate. Noticed a minor error in your protoclass.js file. The comma at the end of line 34 means this code won't work in IE :)

    Cheers!
  2. kernel1983:
    2010-03-27 01:44
    fix that for IE! files updated
Leave a Comment:
code:730