I made a small example of using the json output of the R.U.B.E. box2d editor (
http://www.iforce2d.net/b2deditor/) to create and display a box2d world. It uses the JSON4Lua library (JSON4Lua library:
http://json.luaforge.net/) to read the json output and convert it to a lua table. Some ugly lua code that I wrote (with help from atilim -- thanks!) then converts the lua table to a box2d world.
The code & simple gideros project can be found at:
https://bitbucket.org/ndoss/gideros_playgroundOne question I have about the box2d implementation in gideros -- is there a way to interact with the box2d elements if using b2.DebugDraw?
Comments
To interact with the box2d elements, you can follow these steps:
1. Get the fixtures under the mouse/touch by using b2.World:queryAABB function. Creating a small AABB (e.g. with size 0.001) around mouse coordinate is enough:
2. If you get a fixture, get the body from the fixture and create a mouse joint:
Elastic Joints example shows creating and destroying mouse fixture.
(Also there is an open source project by @Stoffe that converts paths and positions in Inkscape to Lua tables: http://www.giderosmobile.com/forum/discussion/130/box2d-editor#Item_6)
Could you post a tutorial or a more detailed read me file, for getting it to work?
What are you having trouble with?
After downloading the code in bitbucket, all you have to do to run the demo is to load the project file with GiderosStudio and run it through the GiderosPlayer.
createBox2dWorld.lua:34: shape must exist in fixture definition table
Ndoss, would you have an updated version (before I start hacking the code)?
If Gideros box2d API is similar to original box2d API, the challenge will be port b2djson to Gideros lua code.
A plugin will be more difficult because it will need access to native C++ box2d API