Hello all,
I’ve been trying to figure this one out and can’t seem to get it. I just want to change the value of a global variable “a” from scene to scene using director by reloading a file. I check the forum don’t seem to get this concept very well. Can some one please give me an example on how to do this? Thank you. Any help will be appreciated. Here’s an example.
level1.lua
module(…, package.seeall)
a=1 —define global variable a in level1.lua
–Director change scene to level2.lua.
Level2. lua
module(…, package.seeall)
local btn1=display.NewImage(…)
–director change scene back to level1.lua when btn1 is touch and change the global variable “a” in level1.lua from a=1 to a=2
–in level2.lua I am basically reloading level1.lua when the button is touch and change the variable a=1 in the file level1.lua to a=2
Level3. lua
module(…, package.seeall)
local btn2=display.NewImage(…)
–director change scene back to level1.lua when btn2 is touch and change the global variable “a” in the file level1.lua from a=2 to a=3
–in level3.lua I am basically reloading the file level1.lua when btn2 is touch and change the variable this time a=2 in level1.lua to a=3.
Any help would be appreciated.
[import]uid: 104131 topic_id: 21123 reply_id: 321123[/import]
