Hi,
I’ve started learning Corona SDK today.
I have no experience with this SDK or Lua.
I have a very simple demo which is not working as intended:
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local TextSize = 0 local TextSizeDir = 1 if TextSizeDir == 1 then if TextSize \<= 50 then TextSize = TextSize + 1 else TextSizeDir = 0 end elseif TextSizeDir == 0 then if TextSize \>= 0 then TextSize = TextSize - 1 else TextSizeDir = 1 end end local displayText = display.newText( "Hello World", display.contentCenterX, display.contentCenterY, "Font01.ttf", TextSize )
The above code *should* animate the “Hello World” text in the center of the screen (larger, smaller & repeat).
It does not do anything currently because at beginning of each main.lua loop the following is reset:
local TextSize = 0 local TextSizeDir = 1
I am coming from C++ programming language and want to make the above two variable global like in C++.
How would I declare the above two variables globally and then initialize their values only once at app start?
Also, if there is anything else wrong with above then please let me know…
(“Font01.ttf” is a valid TTF font in the project’s main directory)
Thanks!
JeZxLee