Hi,
I’m trying to create a tab menu, each tab goes to a new scene (three lua files). When I navigate from my menu screen to my tabMenu I get the following error:
bad argument #-2 to ‘insert’ (Proxy expected, got nil)
Which is resolved by commenting out the following line in my exitScene function (which shouldn’t be the correct solution, right?):
storyboard.purgeScene(storyboard.getCurrentSceneName() )
Then the next problem. On the top of my screen I created a button bar with back and a search button, below the button bar is the tab button bar. With my current code, when I enter the ‘tabMenu’ from ‘menu’, the ‘tabMenu’ gets “overwritten” because of the ‘storyboard.gotoScene( “catagory” )’ line. I get what is happening, I added the buttons before I called the goToScene so it makes sense that the buttons are below the ‘catagory’. See my current code below:
local buttonBar = display.newRect(group, centerX,25,display.contentWidth, 50) buttonBar:setFillColor(0,0,0) group:insert(buttonBar) backBtn = display.newText("Back", 0,0, native.systemFontBold,30) backBtn.x = 10 + backBtn.width \* 0.5 backBtn.y = buttonBar.y backBtn.align = "left" backBtn:setTextColor(0.5,0.5,0.5) backBtn.destination = "menu" backBtn:addEventListener("tap", onButton) group:insert(backBtn) searchBtn = display.newText("Search", 0,0, native.systemFontBold,30) searchBtn.x = display.contentWidth - backBtn.width \* 0.5 searchBtn.y = buttonBar.y searchBtn.align = "right" searchBtn:setTextColor(0.5,0.5,0.5) searchBtn.destination = "menu" --temporary searchBtn:addEventListener("tap", onButton) group:insert(searchBtn) local tabButtons = { { label = "Catagory", defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png", width=32, height=50, onPress = function() storyboard.gotoScene( "catagory" ); end, selected = true }, { label = "All", defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png", width=32, height=50, onPress = function() storyboard.gotoScene( "all" ); end, }, { label = "Combi", defaultFile = "assets/tabIcon.png", overFile = "assets/tabIcon-down.png", width=32, height=50, onPress = function() storyboard.gotoScene( "combination" ); end, } } local tabBar = widget.newTabBar { top = 50, width = display.contentWidth+ox+ox, backgroundFile = "assets/tabIcon-background.png", tabSelectedLeftFile = "assets/tabIcon-background.png", tabSelectedRightFile = "assets/tabIcon-background.png", tabSelectedMiddleFile = "assets/tabIcon-background.png", tabSelectedFrameWidth = 40, tabSelectedFrameHeight = 50, buttons = tabButtons } group:insert(tabBar) storyboard.gotoScene( "catagory" )
When I place the buttonBar, backBtn and searchBtn creation below the ‘storyboard.gotoScene(“catagory”)’ line, the buttonBar, backBtn, searchBtn and the tabBar are all gone!
Messing around, I discovered that only commenting out the ‘group:insert(tabBar)’ line makes everything appear again but the functionality of going from the ‘tabMenu’ back to the ‘menu’ results in the following error (as before):
bad argument #-2 to ‘insert’ (Proxy expected, got nil)
Again messing around, I removed the storyboard.purgeScebe line from the exitScene function of all tab scenes, which more or less works but now all the buttons are still there when going back to the ‘menu’.
I hope this post makes scene because this situation does not make any to me anymore…