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...") |
|||
| Line 14: | Line 14: | ||
if camera then | if camera then | ||
--create a form window of size 20% screen width and 20% screen height. | --create a form window of size 20% screen width and 20% screen height. | ||
form = Form(camera, PanelSize(Vec2(0.2,0.2))) | form = Form(camera, PanelSize(Vec2(0.2,0.2), "form-name")) | ||
--Set layout default is FlowLayout. | --Set layout default is FlowLayout. | ||
form:setLayout(FallLayout()) | form:setLayout(FallLayout()) | ||
Latest revision as of 17:37, 24 August 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), "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