I keep learning a little more each day.
Hopefully someone can comment on the piece of the puzzle I might be missing
Here is my main.lua
I’ve figured out I can call the loadScreen function from within a button on my Screen2.lua.
I just can’t figure out how to keep the Tab Bar from dissapearing as when I call the loadScreen function within my button my whole screen changes to Scene3.lua for example.
Here is my my main.lua and right after is my Scene2.lua that i need to find out what I have to add to make the scene change to only show up in the tabView Group that is in the main.lua.
Can I do that write my button to target the Scene change in the main.lua so it leaves my tab bar on the screen and changes scenes appropriately.
Th director version is working finicky so I keep jumping back and forth until I can get this, seems to be the last piece of the puzzle for me for my entire project.
Any help would be greatly appreciated.
[lua]display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar
–import external classes
local director = require(“director”)
local ui = require(“ui”)
local viewController = require(“viewController”)
local scrollView = require(“scrollView”)
local util = require(“util”)
local fps = require(“fps”)
local mainView, tabView, currentScreen, tabBar
local function loadScreen(newScreen)
if currentScreen then
currentScreen:cleanUp()
end
currentScreen = require(newScreen).new()
tabView:insert(currentScreen)
return true
end
local function showScreen(event)
local t = event.target
local phase = event.phase
if phase == “ended” then
if t.id == 1 then
loadScreen(“screen1”)
elseif t.id == 2 then
loadScreen(“screen2”)
elseif t.id == 3 then
loadScreen(“screen3”)
elseif t.id == 4 then
loadScreen(“screen4”)
end
tabBar.selected(t)
end
return true
end
local function init()
–Create a group that contains the entire screen and tab bar
mainView = display.newGroup()
–}}
local performance = fps.PerformanceOutput.new();
performance.group.x, performance.group.y = display.contentWidth * .9, display.contentHeight * .15;
performance.alpha = 0.2
–Create a group that contains the screens beneath the tab bar
tabView = display.newGroup()
mainView:insert(tabView)
loadScreen(“screen1”)
tabBar = viewController.newTabBar{
background = “tabBar.png”, --tab bar background
tabs = {“News”, “Tools”, “Resources”, “Products”}, --names to appear under each tab icon
onRelease = showScreen --function to execute when pressed
}
mainView:insert(tabBar)
tabBar.selected()
return true
end
–Start the program!
init()[/lua]
Scene2.lua
[lua]module(…, package.seeall)
function new()
local g = display.newGroup()
local background = display.newRect(0,display.screenOriginY, display.contentWidth, display.contentHeight-display.screenOriginY)
background:setFillColor(255, 255, 255)
g:insert(background)
local message = display.newText(“Screen 2”, 0, 0, native.systemFontBold, 16)
message:setTextColor(0, 0, 0)
message.x = display.contentWidth*0.5
message.y = display.contentHeight*0.5
g:insert(message)
function loadScreen(newScreen)
– if currentScreen then
– currentScreen:cleanUp()
– end
currentScreen = require(newScreen).new()
– tabView:insert(currentScreen)
return true
end
local arrowPress = function( event )
end
local OnRelease = function( event )
if event.phase == “ended” then
loadScreen(“screen1”)
end
end
local buttonArrow = ui.newButton{
default = “buttonArrow.png”,
over = “buttonArrowOver.png”,
onPress = arrowPress,
onRelease = OnRelease,
text = “arrow”,
textColor = { 255, 255, 255, 0 },
id = “arrow”,
size = 30,
align = “center”,
emboss = true,
}
g:insert(buttonArrow)
buttonArrow.x = display.contentWidth * .50
buttonArrow.y = display.contentHeight * .5
function g:cleanUp()
g:removeSelf()
end
return g
end[/lua]
[import]uid: 50045 topic_id: 9462 reply_id: 34696[/import]