I am in the process of creating my first ever game for the mobile device and using Corona to do it in the Lua scripting language.
I've heard when creating each level inside a different file it is more memory-smart to put everything that stays the same into one logic file and load it inside each level file. What type of things should be inside this file, functions, sprites etc?
Also, how do I load this in the different files if all my variables are local? I have tried require "logic" - my file name containing all my functions, however I'm not sure how I get the functions written inside to 'activate' because currently they don't.
If you need me to post any code I'm happy to do so. Thanks for reading!
Update
Thanks for giving the idea of tables, I've stored all my functions inside one now, it looks like this:
-- Logic File
local functionTable = {}
functionTable[1] = onTouch,
functionTable[2] = physicsStart,
functionTable[3] = onComplete,
functionTable[4] = winCondition
However I'm struggling to find a way to call these functions in my level files, here is what I have tried which isn't working, do you know of a way to improve this?
-- Level File
local logic = require "logic"
logic.functionTable[1]
logic.functionTable[2]
logic.functionTable[3]
logic.functionTable[4]
When you say store image names or paths, say I have an image called red_apple located in my 'graphics' folder in the root of my project; would the following be correct?
local imagePath = {}
imagePath[1] = graphics/red_apple
Also, my game is 2D so I'm hoping the learning curve isn't too steep although I understand there will be a lot of things I may have never come across and don't understand however I think that is the best way to learn - and a little bit of naivety never hurt as well :P