Adding Cocoon C++ Box2D Physics bridge to your project


#1
  1. Export your project for Cordova.

  2. Download this: cocoon_box2d.js
    or source here: cocoon_box2d.js
    and place it in your project export frolder. It should look like this:

  3. Open index.html in notepad (should be in your export folder), search for the line: script src=“c2runtime.js” then add <script src="cocoon_box2d.js"></script> on top of it and save it. It should look like this:

  4. Open c2runtime.js in notepad (should be in your export folder), search for the line: var b2Vec2 = Box2D.Common.Math.b2Vec2, then add window.Box2D = CocoonBox2D; on top of it and save it. It should look like this:

That’s it. Correct me if I’m wrong because I haven’t really debugged nor tested the performance yet.

Don’t forget to add the new cocoon_box2d.js in your zip when preparing for Cocoon compilation.


[Construct 2] Black Screen
#2

Hi, i’d love this for my project but I’m using prismatic joints. I see in the code that these are not featured. Do you have any idea on how they could be included?

Best regards,
Erik


#3

I don’t think it’s currently supported in C2, Ashley said it’s on the to do list. More on this here -
https://www.scirra.com/forum/prismatic-joints_t65792


#4

Interesting!

What can I do to help with this?


#5

The thread is from 2012, so I think it might be off the to do list :smiley: I’m not sure how to help you further. Maybe @andy_reitberger can say something about this.


#6

I send him a PM but get no response. Who can help me with this? Who is responsible for the box2d plugin? Is it still maintained?


#7

Hi,

Sorry for the late respone. Canvas+ supports Web2D, so it also should support those prismatic joints you mentioned. But I guess C2 is not.

So the easiest way would be to try it, otherwise you have to ask Ashley about that matter again.
He once said that he will consider it, just remind him :wink:

Sorry that I can’t do more at the moment.

Regards
Andy


#8

Just to clarify.

What is Web2D? Does Canvas+ support that natively or with a plugin? Where is the code and docs for web2d?

When you say ask Ashley, do you mean in the Scirra Forums? What is the affiliation between Cocoon.io and Scirra?


#9

Sorry for the missunderstandig, surely I meant box2D, that’s why I should not answer post via my phone :wink:

Yes, just send a mail to support@scirra.com or open a new topic or reply to the linked one.

Scirra offers a tool to create HTML5 games and cocoon is a wrapper converting those games to Android or/and iOS.

Scirra and ludei are two Independent companies.

Regards
Andy


#10

Thank you for the clarification!

However, i fail to see the connection. I’m assuming that Cocoon.io is using this Javascript code as a layer between apps and native box2d code:
https://github.com/CocoonIO/cocoon-canvasplus/blob/master/src/js/device/cocoon_box2d.js

This code assumes that window.ext.IDTK_SRV_BOX2D is set. But, what is Scirra’s role in this code? Isn’t it Cocoon.io that provides the native code that supports Box2d using Canvas+?


#11

Hey Andy, so I’ve been emailing with Scirra.

If i understand it correctly, you are using the native code for box2d he is referring to. This is the code that is using the API looking like this window.ext.IDTK_SRV_BOX2D

So, what can I do to help to make this happen? I have over 1,000 paying customers that would instantly benefit from this and it is also heavily influencing my decision of the upcoming year long game project I will start.


#12

Hi @erik.mattias.larsson

Sorry for the delay.
Thanks for sharing the answer from Scirra, but I cannot do anything to help you in that matter.
It’s something what Scirra has to do, but theY won’t. Maybe the best way is to switch to a diffrent game making editor which supports the physic features you need.

I’m sorry that I cannot do more for you! :frowning:

But maybe @imanolm1 or @andoni.martin can tell you more about the box2d in cocoon.

Regards
Andy


#13

Is accelerated Box2D still a feature of Canvas+? Is there a tutorial or demo of this?

Thanks.