FormExampleCode

From Crumbled World Wiki

Example Code

--this = SceneNode()
function destroy()
	--clear form
	form:destroy()
end

function create()
	--Get the camera wich the form will be renderd to.
	local camera = this:getRootNode():findNodeByName("MainCamera")
	--Check if the camera exist.
	if camera then
		--create a form window of size 20% screen width and 20% screen height.
		form = Form(camera, PanelSize(Vec2(0.2,0.2), "form-name"))
		--Set layout default is FlowLayout.
		form:setLayout(FallLayout())
		--Set background color red.
		form:setBackground(Sprite(Vec4(1,0,0,1)))
		
		--Allign form to top left.
		form:setAlignment(Alignment.TOP_LEFT)
		--Set offset from upper left corner to 200 pixel.
		form:setFormOffset(PanelSize(Vec2(200,200), PanelSizeType.Pixel))	
	end
        return true
end

function update()
	form:update()
	return true
end