Which is better: local foo = require("module1") in each screen OR require("module1") in main.lua?

Hi guys.

I am trying to understand better the use of require (as in require external module like ui, particle candy and so on..)

In some codes here in the forum, I see either:

A- local foo = require("module1")

OR

B- require("module1")

My questions:

1- Which one is better in term of memory usage and application speed?

2- Where do you guys usually put your require statements? In main.lua (using B so the modules are globally accessible)? OR do you require modules as you need them using A? If the latter, what happened if say you need the ui.lua (for buttons) on multiple screens (director)?

Thank you for any pointers. i am having a hard time with a "simple" statement like require!

Mo

views:1517 update:2011/11/10 9:30:09
corona forums © 2003-2011