So as I have understood you should have as many local variables as possible, right?
My problem is that my game is level based with one main lua file named level.lua and then I have one file for each level that says which setups that specific level by changing things in level.lua.
Currently all those things that are changed in level.lua are global variables, is it possible to have local variables and access them from another file? The same question about functions.
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Local variables across files and functions?
Hi,
Local variables are private, so they're inaccessible outside of the current scope. If you want both the speed benefits of local variables plus accessibility from outside your module, you can do something like this in your module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | local MyModule = {} local myVariable = "foo" local function myFunction() print("myFunction()") end function getMyVariable() return myVariable end MyModule.myFunction = myFunction return MyModule |
Thanks!
views:1628 update:2011/11/26 9:01:35
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
Link to Review on NOOK - are intents required? Workarounds?
Moving objects while being affected by physics
Can't build for device
Cannot render rotated text object
Object moves on a defined path example ?
Bezier Curves, SVG Parser for Box 2D etc.
Hard crash with native elements on device?
Need help insert object
access to ipod music library
portraitUpsideDown in the simulator
Moving objects while being affected by physics
Can't build for device
Cannot render rotated text object
Object moves on a defined path example ?
Bezier Curves, SVG Parser for Box 2D etc.
Hard crash with native elements on device?
Need help insert object
access to ipod music library
portraitUpsideDown in the simulator
corona forums © 2003-2011