Hi guys
I've been playing around with variables and have been declaring them in this way
Scene1 = gideros.class(Sprite)
local monkey = 12
function Scene1:init()
print(monkey) |
Basically I have two scenes.
As expected if I print(monkey) in Scene1, I get the number 12.
If I print monkey in Scene2, I get NIL, as monkey was declared as a local in Scene1 lua file
However, if I add 12 to monkey on a touch event etc. inside Scene1 ... goto Scene2 ... and come back to Scene1 ... I now get 24 instead of 12.
Does this mean that the declaration of monkey outside of the scene's init() function only happens on the first time the lua file is loaded?
Thanks guys!
Comments
We had to do it this way to get Macros (which can be used for pseudo equates) working properly.
I think that in any event, variables are made in the order they are seen - as Lua is interpreted. So the order of files in the list can be important.
Likes: antix, Ninjadoodle
https://deluxepixel.com
Thanks for the reply
Will this setup cause me problems with a full export ...
Likes: Ninjadoodle
Likes: Ninjadoodle
https://deluxepixel.com
Likes: Ninjadoodle
Likes: antix