Your Very First Program
Revision as of 00:29, 26 May 2019 by MoKaLux
Now that you have installed Gideros Studio, it would be fun to see how it works.
Let us look at the Hello World example to start with.
Create a new project, give it a name, e.g HelloWorld.
After Gideros Studio starts, right click on the Project window and select "Add New File".
Name it "main.lua" (all projects should have a main.lua file initially).
Coding for the console
The simplest way to display something is on the console. The way to achieve that is using the lua "print" statement.
We type the following code in the main.lua file:
Look in the console output window. You will see those three lines:
main.lua is uploading Uploading finished. Hello World
Coding for the Device
It can be useful to have debugging statements being printed to the console. Now, let us look at how to display Hello World on the device.
Type in the following code:
-- HelloWorld.lua test script -- Create a new text field with the text Hello World! The font -- parameter is set to nil, so Gideros will use the default font local myTextField = TextField.new(nil, "Hello World!") -- Position the text field at the coordinates of 40,100 -- Without this, you won't see the text as with the default -- font it will be placed above the visible canvas area. myTextField:setPosition(40,100) -- Add the text field to the stage stage:addChild(myTextField)
We have successfully created our first code and displayed Hello World! on the device.