EXAMPLE

21
Jun
2012

This blog is written to show how to define a world, body, fixture and render it in Canvas. To view the whole source code - Right Click on Canvas and click "View frame source".



For the above output, add the code to your body.


Add the following in your HTML file within the "html" tag.
   
   

By administrator at 03:28:46 PM 8 Comment(s)

Comments

What's the difference between Box2dWeb-2.1.a.3.min.js and
Box2dWeb-2.1.a.3.js? which one should be used and why?

By haris on 2 Jul, 2014 at 01:03:05 PM

there is no difference. Minified version just means that comments and unneeded white space characters (space, newline, and tab) are removed.

By Administrator on 2 Jul, 2014 at 03:13:01 PM

ok here is my problem: after typing the above code without errors(checked it with firebug).
I get the following problem: If i'm using Box2dWeb-2.1.a.3.min.js i get TypeError: c is undefined (line 208).
if i use Box2dWeb-2.1.a.3.js i get TypeError: gravity is undefined (line 5495).
I never was messing around with those 2 file, just included them in a scritp tag.
Really need help with this one!

By haris on 2 Jul, 2014 at 02:51:24 PM

May I see your code? All of it.

By Administrator on 2 Jul, 2014 at 05:19:12 PM

Feel kinda embarased. Found my mistake. It was in the variable world definition.
Didn't put 'new' in front of b2Vec2(0,10).
Anyhow GREAT site, i'll be visiting quite often!

By haris on 3 Jul, 2014 at 02:28:49 PM

Glad you found your error. And thanks for the encouragement.

By Administrator on 4 Jul, 2014 at 02:26:47 AM

on line 33 bodyDef2 was used but never defined.
same for fixDef2 on line 34.

By sercan ozturk on 7 Apr, 2017 at 07:33:50 AM

@ozturk my bad. same corrected. Thanks.

By Administrator on 8 Apr, 2017 at 06:01:49 PM

Add a Comment

Please enter the email address.Invalid format. (Won't be Displayed)
Notify me of followup comments
Enter the displayed Code: captcha