In this tutorial we will create a "complex" shape, which is basically a concave L type shape. As only convex shapes can be created in box2d, we will use multiple convex fixture to create on concave object.

So let's take Draggable project as a start and modify ii to achieve what we need.

First let's create method, which create this L type body with 2 fixtures. To do that, we need to create to fixtures and position shape's center coordinates, relatively to body's center coordinates, something similar to this image:

After creating this body with 2 fixtures, we store reference to second fixture and it's definition for later use:

-- creating complex objects
-- using multiple fixtures
function scene:Lshape(x, y)
	local shape =
	shape:setFillStyle(Shape.SOLID, 0x0000ff)
	--just a reference size of one square for drawing
	shape.size = 30
	--let's create L shape
	shape:moveTo(shape.size, -shape.size)
	shape:lineTo(shape.size*2, shape.size*2)
	shape:lineTo(shape.size*2, -shape.size*2)
	shape:lineTo(-shape.size*2, -shape.size*2)
	shape:lineTo(-shape.size*2, -shape.size)
	shape:lineTo(-shape.size, -shape.size)
	shape:lineTo(shape.size, -shape.size)
	--create box2d physical object
	local body ={type = b2.DYNAMIC_BODY}
	body:setPosition(x, y)
	body:setAngle(shape:getRotation() * math.pi/180)
	--create first shape
	local poly =
	poly:setAsBox(shape.size/2, shape.size*2, shape.size*1.5, 0, 0)
	local fixture = body:createFixture{shape = poly, density = 1.0, 
	friction = 0.1, restitution = 0.8}
	--create second shape
	local poly =
	poly:setAsBox(shape.size*1.5, shape.size/2, 
		-shape.size/2, -shape.size*1.5, 0)
	--save fixture definition for later use
	local fixtureDef = {shape = poly, density = 1.0, 
	friction = 0.1, restitution = 0.8}
	body.fixDef = fixtureDef
	local fixture = body:createFixture(fixtureDef)
	--save reference to fixture so we can destroy it
	body.fixture2 = fixture
	--is body destroyed
	--so we won't attempt to destroy this body again
	body.destroyed = false
	--save reference to shape object
	body.shape = shape
	--and as usuallu reference to body
	shape.body = body
	shape.body.type = "Lshape"
	--add to scene
	--return created object
	return shape

Then inside init method, we need to call this Lshape method to create this complex body and add event handler, for collision, as we want to break our body on collision.

--create Lshape
local Lshape = self:Lshape(100, 100)

--add collision event listener, self.onBeginContact, self)

Now all we need to do is to define this collision event handler. Inside this event handler, we will destroy second fixture of our L shape body and redraw it, according to fixture that is left.

And then we'll create new body with saved fixture definition and copy current body's position, angle, etc, as we completely want to take the place of destroyed fixture. After that each of the bodies may go it's own way:

--define collision event handler function
function scene:onBeginContact(e)
	--getting contact bodies
	local fixtureA = e.fixtureA
	local fixtureB = e.fixtureB
	local bodyA = fixtureA:getBody()
	local bodyB = fixtureB:getBody()
	--check if second colliding body is a Lshape
	--it should be second, because it was created last
	if bodyB.type and bodyB.type == "Lshape" and not bodyB.destroyed then
		--creating timer to delay changing world
		--because by default you can't change world settings 
		--in event callback function
		--delay 1 milisecond for 1 time
		bodyB.destroyed = true
		local timer =, 1)
		--setting timer callback
		timer:addEventListener(Event.TIMER, function()
			--destroy one fixture for L shape body
			--and now we need to redraw the shape
			--to match fixture that is left
			bodyB.shape:setFillStyle(Shape.SOLID, 0x0000ff)
			bodyB.shape:moveTo(bodyB.shape.size, -bodyB.shape.size*2)
			bodyB.shape:lineTo(bodyB.shape.size*2, bodyB.shape.size*2)
			bodyB.shape:lineTo(bodyB.shape.size*2, -bodyB.shape.size*2)
			bodyB.shape:lineTo(bodyB.shape.size, -bodyB.shape.size*2)
			--create new box2d physical object
			--with same position, etc as L shape was
			local body ={type = b2.DYNAMIC_BODY}
			--copy existing body's position, etc
			local x, y = bodyB:getPosition()
			--add fixture from saved definition
			--create new shape to represent new box2d object
			local shape =
			shape:setFillStyle(Shape.SOLID, 0x0000ff)
			shape:moveTo(bodyB.shape.size, -bodyB.shape.size)
			--save reference to new body
			shape.body = body
			--add dnew shape to scene
		end, self)
		--start timer

As usually, here is an example video:

And, of course, sample Gideros project, to try it out.