I seam to have not used locals at all, just so I can call them from other functions. Is that a bad habit?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
How important are local variables?
its bad for memory heavy games(lots of objects)
So what's the problem with local variables? You can call them from other functions just as easily. The only situation I can think of where you can't access a local variable is when you create it inside a function/module and then try to access it outside that function/module. But creating a global inside a function is a very bad idea.
By using only globals you actually produce spaghetti code and make it harder for yourself to maintain the program as it grows in size. The more modular and independent pieces of your code are, the better.
I will attempt to use locals more then :)
Local variables make your code faster, generally.
Here's a great post on locals as well as some good comments too.
views:1539 update:2011/10/5 8:48:05
热门文章
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
相关文章
network.request()
My Debugger Doesn't Pause Or Allow Me To Enter Commands
Developer to enable "Newsstand" feature to my apps
[iOS] Walkthrough - Building For The App Store
So... who tried Objective C before Corona!?
OAuth authentication
Pipclock featured on TA!
Older iOS devices crashing
How to make train on railroad tracks?
[SOLVED] Proper plist for OTA distribution
My Debugger Doesn't Pause Or Allow Me To Enter Commands
Developer to enable "Newsstand" feature to my apps
[iOS] Walkthrough - Building For The App Store
So... who tried Objective C before Corona!?
OAuth authentication
Pipclock featured on TA!
Older iOS devices crashing
How to make train on railroad tracks?
[SOLVED] Proper plist for OTA distribution
corona forums © 2003-2011