hmm. that is sure weird. here is the full code, just to be clear
–main.lua
dir = require('director') button = require('menuButton') \_w = display.contentWidth \_h = display.contentHeight wh = \_w\*0.5 hh = \_h\*0.5 \_sysLangStr = system.getPreference( 'ui', 'language' ) display.setStatusBar(display.HiddenStatusBar) if not string.find( 'de|fr|en|it|es', \_sysLangStr ) then \_sysLangStr = 'en' end dir.changeScene('mainMenu')
–menuButton.lua
local \_={} function \_.createBackButton( group, x, y, width, height, param) --collect for parameter local world = param.world --create back button local backBut = display.newRect(group, x, y, width, height) --putting properties backBut.alpha = 0.5 backBut.isHitTestable = true backBut:addEventListener( 'tap', function() print('change scene') if world == 0 then dir.changeScene('mainMenu') end end) end function \_.createSubMenuButton(group, x, y, width, height, param) --collect for parameter local world = param.world local wName = param.wName local number = param.number --print(world) --create submenu button local subMenu = display.newRect(group, x, y, width, height) --putting properties subMenu.alpha = 0.5 subMenu.isHitTestable = true subMenu:addEventListener( 'tap', function() print('change scene') dir.changeScene('subMenu'..number, {worlds = world, worldName = wName}) end) end return \_
–director.lua
local \_={} local sceneName = 'main' local sceneGroup function \_.changeScene( newScene, par ) display.remove(sceneGroup) sceneGroup = nil --purging all previous group package.loaded[sceneName] = nil -- unload the module of the scene collectgarbage() collectgarbage() sceneGroup = require(newScene).new(par) sceneName = newScene end function \_.getSceneName() return sceneName end return \_
–mainMenu.lua
\_.new = function(params) local group = display.newGroup() local num = 1 --which subMenu identified with numbers --creating background local bgimg = display.newImage( group,'0141MULTI-Wimmel\_Puzzle/1-Design/2-Final/01\_mainmenu/ipad/mainmenu\_'..\_sysLangStr..'\_ipad.jpg', wh, hh) --setting up size and coordinates defX = 215 defY = 265 defWid = 250 defHei = 190 --creating submenu button button.createSubMenuButton(group, defX, defY, defWid, defHei, {world = 1, wName = 'bauernhof', number = num}) button.createSubMenuButton(group, defX+287, defY, defWid, defHei, {world = 2, wName = 'hafen', number = num}) button.createSubMenuButton(group, defX+574, defY, defWid, defHei, {world = 3, wName = 'polizei', number = num}) button.createSubMenuButton(group, defX, defY+252, defWid, defHei, {world = 4, wName = 'jahrmarkt', number = num}) button.createSubMenuButton(group, defX+287, defY+252, defWid, defHei, {world = 5, wName = 'spielplatz', number = num}) button.createSubMenuButton(group, defX+574, defY+252, defWid, defHei, {world = 6, wName = 'zoo', number = num}) return group end return \_
here’s the big picture: every time I want to change into a new scene, I use director.lua to direct into other .lua files. Each of the menu button is created through the menuButton.lua, so the creation method can be useable over time. the problem is when i try to use a menu button creation (using main menu as example) it get stuck when the variable name is like,
dir.changeScene('subMenu', {world = world})