I have encountered the problem of too many local variables again. This is occurring in my Screen1.lua file and I did make the effort to put all my variables into an array/object like this:
local splashVariables = {}
splashVariables["boolExtraFeatures"] = true
splashVariables["numBallOptionStage"] = 1
splashVariables["numTipsPage"] = 1
splashVariables["numInstructionsPage"] = 1
splashVariables["numAchievementsPage"] = 1
splashVariables["optionsDisplayed"] = false
The problem is however not with variables as such but instead with functions and some images I need to have a reference to. I can’t believe that there are 200 of these but guess there is as there is over 4000 lines of code in this lua file
e.g
local function cancelTransitions()
Runtime:removeEventListener("enterFrame", animateScroller)
if splashPanelTrans ~= nil then
transition.cancel(splashPanelTrans)
end
end
local fadeBg = display.newImage("images/fade.png", -1000, -1000)
localGroup:insert(fadeBg)
function displayFadeBg()
fadeBg.alpha = 0
fadeBg.x = 160
fadeBg.y = 240
transition.to( fadeBg, { time=250, alpha=1} )
fadeBg:addEventListener("touch", clickFadeBg)
end
Has anyone any suggestions how to reduce the number of functions or image references. Can I do something like?
[code]
splashVariables[“fadeBg”] = display.newImage(“images/fade.png”, -1000, -1000)
[/code] [import]uid: 7863 topic_id: 6172 reply_id: 306172[/import]