Hi everyone,
I'm transitioning my game from a one file mess to using external modules and Director but I'm having a problem with inserting images to groups. I'm guessing it's easy to do and I tried searching for answers but I just can't figure it out.
Basically I have main.lua to launch game.lua scene and inside game.lua I have it localizing game_init.
I get an error that says "attempt to index global 'groupBg' (a nil value) when I try to insert "bg" into "groupBg" (line 9 of game_init.lua). Any help would be great!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - game.lua module(..., package.seeall) new = function () ------------------ -- Groups ------------------ local localGroup = display.newGroup() groupBg = display.newGroup() localGroup:insert( groupBg ) ------------------ -- Your code here ------------------ local gameInit = require( "game_init" ) gameInit.gameSetup() ------------------ -- MUST return a display.newGroup() ------------------ return localGroup end |