[FREE] Box2D - Java Physics Engine for games

Now we can make some really cool game.

WHAT IS BOX2D?

You maybe did not heard of Box2D, but you must know AngryBird, which is made with Box2D.

Box2D is a 2D rigid body simulation library for games. Programmers can use it in their games to make objects move in realistic ways and make the game world more interactive. From the game engine's point of view, a physics engine is just a system for procedural animation.

You can refer here Box2D for details.

BASIC KNOWLEDGE

BoxWorld:

First we need a BoxWorld, with gravity like real world.
We can add Body in this BoxWorld.

BoxBody:

Now we can create Circle, Rectangle, Polygon, Edge body, and destry them if needed.
We have 3 type bodies: DYNAMIC, STATIC, KINEMATIC.

BoxJoint:

Now we can create MouseJoint, RevoluteJoint, DistanceJoint.

ALL BLOCKS

In BoxWorld we have:

image

in BoxBody, we have:





image

in BoxJoint, we have:



HOW TO USE?

it's so easy, just create a world, set the gravity if needed, add some bodies, then other things like falling down, bouncing, colliding will be done by Box2D.
Please do check the demo aia before use this extension or ask for help.

NOTICE

  1. Location in this extension (like x, or y) is in pixel (did not devided by screen density).

  2. Angle are in degree, not radian.

  3. The position of the body is refer to its center ( not like in Canvas, it refer to imagesprie's left top corner).

AIX DOWNLOAD:

cn.kevinkun.Box2D.aix (420.1 KB)

DEMO

box2D_V1.aia (521.0 KB)

OTHER

Box2d libary is a big one, there are many functions not implemented here. If you want to sponsor more functions, please PM me.
or you want to donate for this extension by PM me also.

14 Likes

This is truly a great extension.
It's a shame that App Inventor doesn't yet have a functional canvas.
Very good, congratulations

Maybe it's a good idea to expose some function to show the body on the Canvas.

Compared to a canvas element in html there is a big difference