FormExampleCode: Difference between revisions
From Crumbled World Wiki
(Created page with "==Example Code== <syntaxhighlight lang="lua"> --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))) --Set layout default is FlowLayout. form:setLayo...") |
(No difference)
|
Revision as of 07:58, 6 July 2025
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)))
--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