I am using the modified Director Class that removed the module function: https://gist.github.com/1201974
Getting into a bit of a muddle with structuring my code and scoping
I have a scene game.lua
In this scene I create 3 main display groups as follows:
local keyFramesClass = require("keyFrames")
M.new = function ()
local localGroup = display.newGroup()
local backgroundGroup = display.newGroup()
local foregroundGroup = display.newGroup()
local interfaceGroup = display.newGroup()
localGroup:insert(backgroundGroup)
localGroup:insert(foregroundGroup)
localGroup:insert(interfaceGroup)
displayKeyFrame("startGame")
I want to add a graphic to one of these display groups from another “module” called keyFrames.lua
local difficultyLevelPanelClass= require("difficultyLevelPanel")
function displayKeyFrame(passedKeyFrameID)
if (passedKeyFrameID == "startGame") then
local difficultyLevelPanel = difficultyLevelPanelClass.newDifficultyLevelPanel()
foregroundGroup:insert(difficultyLevelPanel)
I am getting the following error
attempt to index global ‘foregroundGroup’ (a nil value)
Any ideas what I am doing wrong here?
[import]uid: 7863 topic_id: 16067 reply_id: 316067[/import]
[import]uid: 3826 topic_id: 16067 reply_id: 59742[/import]