Usually in all tutorials we were creating a bounding box using 4 rectangles on each side of the screen. But since new release of Gideros, there is now a ChainShape available that can not only creating a bounding box, but also create terrain needed in your application.

So let's take a draggable example and modify it to create a little terrain using ChainShape object.

Here we will replace wall function with terrain function:

function scene:terrain(width, height)
	local body = self.world:createBody{type = b2.STATIC_BODY}
	body:setPosition(0, 0)
	
	--set surroungind box
	local chain = b2.ChainShape.new()
	chain:createLoop(
		0,0,
		0, height,
		width, height,
		width, 0
	)
	body:createFixture{shape = chain, density = 1.0, 
	friction = 1, restitution = 0.3}
	
	--create bumpy ground
	--define points in table 
	--and unpack them for function
	local chain = b2.ChainShape.new()
	local chainPoints = {}
	for i = 0, width, 80 do
		table.insert(chainPoints, i)
		if (i/80) % 2 == 0 then
			table.insert(chainPoints, height)
		else
			table.insert(chainPoints, height - 40)
		end
	end
	chain:createLoop(unpack(chainPoints))
	body:createFixture{shape = chain, density = 1.0, 
	friction = 1, restitution = 0.3}
	
	--create a jut
	local chain = b2.ChainShape.new()
	chain:createLoop(
		width, height/3,
		width - width/5*4, height/3,
		width - width/5*4, height/3 + 20,
		width, height/3 + 20
	)
	body:createFixture{shape = chain, density = 1.0, 
	friction = 1, restitution = 0.3}
	
end

And now inside init function, instead of creating for walls, let's just call our terrain function:

self:terrain(application:getContentWidth(), application:getContentHeight())

As usually, here is a video example:

And an sample Gideros project.