Hey Rob,
I’m trying to use your sample business app as an added functionality on top of my app. I’m trying to place the contents of your main.lua file into its own composer scene, but I’m having trouble keeping myApp.tabBar around and getting rid of it when transitioning to scene to scene and back to my main game screen.
Here’s my code:
In main.lua:
\_G.HQTab=display.newGroup() \_G.HQTab.x, \_G.HQTab.y = \_W,\_H local display\_stage = display.getCurrentStage() display\_stage:insert( composer.stage ) display\_stage:insert( \_G.HQTab )
In devMenu.lua (adapted from your main.lua):
local composer = require ( "composer" ) local widget = require( "widget" ) local json = require( "json" ) local myApp = require( "HQ.myapp" ) local sheetLoader = require("sheetLoader") local scene = composer.newScene() math.randomseed(os.time()) -- -- Load our fonts and define our styles -- function scene:create( event ) local sceneGroup = self.view if (display.pixelHeight/display.pixelWidth) \> 1.5 then myApp.isTall = true end if display.contentWidth \> 320 then myApp.is\_iPad = true end local tabBarBackgroundFile = "images/tabBarBg7.png" local tabBarLeft = "images/tabBar\_tabSelectedLeft7.png" local tabBarMiddle = "images/tabBar\_tabSelectedMiddle7.png" local tabBarRight = "images/tabBar\_tabSelectedRight7.png" myApp.topBarBg = "images/topBarBg7.png" local iconInfo = { width = 40, height = 40, numFrames = 20, sheetContentWidth = 200, sheetContentHeight = 160 } myApp.icons = graphics.newImageSheet("images/ios7icons.png", iconInfo) if system.getInfo("platformName") == "Android" then myApp.theme = "widget\_theme\_android" myApp.font = "Droid Sans" myApp.fontBold = "Droid Sans Bold" myApp.fontItalic = "Droid Sans" myApp.fontBoldItalic = "Droid Sans Bold" myApp.topBarBg = "images/topBarBg7.png" else myApp.theme = "widget\_theme\_ios7" local coronaBuild = system.getInfo("build") if tonumber(coronaBuild:sub(6,12)) \< 1206 then myApp.theme = "widget\_theme\_ios" end myApp.font = "HelveticaNeue-Light" myApp.fontBold = "HelveticaNeue" myApp.fontItalic = "HelveticaNeue-LightItalic" myApp.fontBoldItalic = "Helvetica-BoldItalic" end widget.setTheme(myApp.theme) myApp.tabBar = {} function myApp.showScreen1() myApp.tabBar:setSelected(1) --composer.removeHidden() composer.gotoScene("HQ.menu", {time=250, effect="crossFade"}) return true end function myApp.showScreen2(event) myApp.tabBar:setSelected(2) local options = { feedName = "outcast.rss", feedURL = "http://www.simplemachine.co/?cat=60&feed=rss2", icons = "fixed", displayMode = "webpage", pageTitle = "The Outcast" } --composer.removeHidden() composer.gotoScene("HQ.feed", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen3() myApp.tabBar:setSelected(3) --composer.removeHidden() composer.gotoScene("HQ.photogallery", {time=250, effect="crossFade"}) return true end function myApp.showScreen4() myApp.tabBar:setSelected(4) local options = { feedName = "video.rss", feedURL = "http://gdata.youtube.com/feeds/mobile/playlists/PLUqsW7siiOQScFgxcIi-upYV7wAmsgWCL?max-results=20&alt=rss&orderby=published&format=1", icons = "fixed", displayMode = "videoviewer", pageTitle = "The Outcast Videos" } --composer.removeHidden() composer.gotoScene("HQ.feed2", {time=250, effect="crossFade", params = options}) return true end function myApp.showScreen5() print("Making the call to update...") local sheetArray = sheetLoader.new() return true end local function closeMenu() print("YEEEEAHHAHAHAH") local function killNav() composer.gotoScene("scene1", "crossFade", 400) -- end --myApp.tabBar:removeSelf() transition.to(myApp.tabBar, {time=300, transition=easing.inOutQuad, onComplete=killNav}) return true end local tabButtons = { { label = "", defaultFile = "images/tabbaricon\_main.png", overFile = "images/tabbaricon\_main\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen1, selected = true, }, { label = "", defaultFile = "images/tabbaricon\_blog.png", overFile = "images/tabbaricon\_blog\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen2, }, { label = "", defaultFile = "images/tabbaricon\_pic.png", overFile = "images/tabbaricon\_pic\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen3, }, { label = "", defaultFile = "images/tabbaricon\_vid.png", overFile = "images/tabbaricon\_vid\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = myApp.showScreen4, }, { label = "", defaultFile = "images/tabbaricon\_exit.png", overFile = "images/tabbaricon\_exit\_down.png", labelColor = { default = { 0.25, 0.25, 0.25 }, over = { 0.768, 0.516, 0.25 } }, width = 32, height = 32, onPress = closeMenu, }, } myApp.tabBar = widget.newTabBar{ top = -50 + display.contentHeight/2, left = 0, width = display.contentWidth\*2, backgroundFile = tabBarBackgroundFile, tabSelectedLeftFile = tabBarLeft, -- New tabSelectedRightFile = tabBarRight, -- New tabSelectedMiddleFile = tabBarMiddle, -- New tabSelectedFrameWidth = 20, -- New tabSelectedFrameHeight = 50, -- New buttons = tabButtons, height = 50, background="images/tabBarBg7.png" } -- -- now make the first tab active.align -- --sceneGroup:insert(background) --sceneGroup:insert(myApp.tabBar) --sceneGroup:insert(background) \_G.HQTab:insert(myApp.tabBar) end function scene:show( event ) local sceneGroup = self.view myApp.showScreen1() end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) return scene
Any pointers on how to make this entirely composer-based? Thanks!