Page 1 of 1

[ANN] JavaScript bindings for Chipmunk

Posted: Sun Sep 23, 2012 3:38 pm
by riq
Hi community,

I created JavaScript bindings for Chipmunk v6.1.1.

The generated JavaScript API is compatible with the Chipmunk-JS project ( https://github.com/josephg/chipmunk-js )

That means, that if you create a Chipmunk project using the JS API:
  • it can run on mobile devices / PCs at native speed (by using the Chipmunk JS bindings)
  • or it can run on the web (by using the Chipmunk-JS)
and without changing a single line of code.


Bugs / Features / Status:
Features:
- Currently it supports all the basic Chipmunk functionalities like, Space, Body, all types of shapes, all types of joints, collision detection callbacks.
- The API is 95% compatible with the Chipmunk-JS project. It still has some small incompatibilities which I will try to fix in the next days / weeks.
- The JS code is executed by the SpiderMonkey VM (bundled with the project).
- Supported Platforms: Although in theory should work (with little changes) on every Chipmunk supported platform it was tested only on OS X and iOS. Android version coming soon.
- For the moment there is no documentation, but the easiest way to start a Chipmunk + JS Bindings project is by downloading cocos2d-iphone (develop-v2 branch) ( https://github.com/cocos2d/cocos2d-iphone/ ), install the Xcode templates, and start a "cocos2d iOS with JavaScript" project (it includes the Chipmunk JS bindings as well).
- The bindings are automatically generated. So it should be easy to update them in case new features are added to the C Chipmunk library.
- Status: Alpha. Early adopters are welcome!

This project is part of a bigger project to create multiplatform games in JS using Chipmunk as the physics engine, and cocos2d as the game engine.
Info: https://github.com/cocos2d/cocos2d-ipho ... JavaScript

Sample game:
- From cocos2d-iphone (develop-v2)
https://github.com/cocos2d/cocos2d-ipho ... with_me.js

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Mon Sep 24, 2012 2:29 pm
by slembcke
Looks like it's shaping up nicely.

I'll have to figure out what to do about adding bindings for Pro level features soon it looks like. :)

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Mon Sep 24, 2012 7:12 pm
by riq
slembcke wrote:Looks like it's shaping up nicely.

I'll have to figure out what to do about adding bindings for Pro level features soon it looks like. :)

If you need help in adding JS bindings for Chipmunk Pro, let me know. I can help you with that.

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Tue Sep 25, 2012 8:29 pm
by riq
Update:
  • I Fixed more compatibility issues with Chipmunk-JS.
  • I have just "ported" (it was simple copy & paste) the Chipmunk-JS tests to Chipmunk + JS Bindings. The physics code is 100% the same. No changes!!
Image
Image
Image
Image

Test's source code:
- https://github.com/cocos2d/cocos2d-ipho ... hipmunk.js

Todo:
- Add support for "dragging" objects in the tests.

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Thu Sep 27, 2012 7:56 pm
by riq
Buoyancy tests ported :-)

Image

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Wed Nov 07, 2012 8:08 pm
by riq
I have just released cocos2d v2.1-beta3: http://www.cocos2d-iphone.org/forum/topic/69175

It includes:
- @slembcke's Chipmunk additions: CCPhysicsDebugNode and CCPhysicsSprite
- JS Bindings for Chipmunk which are compatible with Chipmunk-JS

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Tue Nov 13, 2012 4:42 pm
by riq
Update:

The Chipmunk's extensions for cocos2d (PhysicsSprite and PhysicsDebugNode) were also added in the cocos2d-html5 project.
That means that your cocos2d + chipmunk game can run on the web (using Chipmunk-JS and cocos2d-html5) and mobile (using cocos2d-iphone or cocos2d-x and chipmunk + JS bindings) without changing a single line of code!!

Demo (Select the Chipmunk Test):
http://www.cocos2d-iphone.org/t/js-tests/

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Tue Nov 13, 2012 5:51 pm
by slembcke
Huh, that's actually pretty cool. I wish I had more time to play around with it. :-\

Re: [ANN] JavaScript bindings for Chipmunk

Posted: Tue Dec 04, 2012 10:21 pm
by riq
We have just released a new version of cocos2d that features Chipmunk-JS, and includes new samples.
The release notes are here:
http://www.cocos2d-iphone.org/archives/2196

You can play Watermelon With Me (a Chipmunk + cocos2d game) online from here:
http://www.cocos2d-iphone.org/t/js-test ... lonWithMe/

Image