You have to save the result of that function to a var, then, in the draw loop of the game the properties of that body are accesible, like body.position, body.radius, body.linearVelocity, body.angularVelocity, body.mass, etc. I recommend you to open the level definitions of the game Crayon Physics to understand how it works.
But it would be so simple to change to actual code for any language, you can find a Box2D lib for almost every language (Flash as3, c++, objc, java, javascript, java+processing,etc), this is in ObjC. Well.the exact sintaxis depends of the implementation of the API, in this article I'm using this because it is the simplest code I can find.
Once you have defined a body shape, there are different behaviours,or body types:
Like edge but you can close (would be like a POLYGON but is not a convex hull) or not (like EDGE but with more than 2 points) Used for closed shapes like basic geometry (not circles), it uses a list of vertices (x,y) defined with the order specified by each APIįor walls, grounds,etc, Lines with only 2 points: start and end. You have to know that there is some kind of shape types in Box2D : Local body = physics.body(POLYGON, unpack( points ) ) It is pretty simple actually, you have to save each point coordinate of the trace from the mouse/touch start to end, when the release event occurs, then you call to a function of Box2D that creates a polygon with a serie of points, something like this: In Crayon Physics: you can craw something in the screen with your fingers or the mouse, for example a circle, a triangle or a rectangle,and, as you release the mouse/touch, the lines will turn into a solid physical object (in the virtual world). Thomas was alone, Angry Birds, Crayon Physics I have designed 6 dimensions in my game, I'm using the same idea like a process capable of bring to your mind how are made features, so, before you say anything I'm writting near the dimension, the games from which we are replicating its physics, mechanics and art techniques.
I asked myself this same question more than a year ago, and the game 6 Dimensions is the answer ,it is a creative box where each dimension contains a different set of game mechanics using Box2d physics, mixed with visual art techniques, that I am sharing with you, because I made this game to improve a game engine called Codea (the guys from Crabitron), and finally, to write tutorials like this, where I wanted you and me to learn about realistic physics, art and game design.,together we are going to improve our game development skills. We are here today to study the physics of those games and to understand what are they made of, with Box2D.īut, more than the "what", it is much better to know the "how", first of all, let me ask you a question: if you would have to replicate a physics game mechanic or behaviour, will you have the skills and techniques to do so? If you take a look to the list of the top games in the markets, flash-games portals,etc, what can you see?, there are a lot of 2D games with an outstanding use of physics and visual arts!.