Note: I have posted a topic similar to this about 6 days ago but I couldn’t find the thread after an hour of searching. I found the thread using Google but it would just take me to the main page of the forums.
My problem is that I have a title screen which has a play button and a credits button. When I click on the credits button, new objects are displayed while the title screen objects are set to invisible using the [lua]titleView.isVisible = false[/lua] function. However, I cannot figure out how to go back to the title view from that credits view. I wanted it so that whenever the background of the credits view screen was clicked, it would go back to the title view. Here is my code:
[lua]
–> Add physics engine, start up the engine, and apply engine
local physics = require(“physics”)
physics.start()
–>Set gravity to act “down” (ie, toward bottom of the device)
physics.setGravity(0, 2.5)
–>Displays Background
local background = display.newImage (“Title Screen.png”)
–>Requires Storyboard API
local storyboard = require “storyboard”
–>Displays Play Game Button
local playgame = display.newImage (“playBtnBigger.png”)
playgame.x = display.contentWidth/2
playgame.y = display.contentHeight - 160
–>Displays Credits Button
local credits = display.newImage (“creditsBtnBigger.png”)
credits.x = display.contentWidth/2
credits.y = playgame.y + 60
–>Group into Title View
local titleView = display.newGroup(background, playgame, credits)
–>Add Tap Event for Play Game
function startGame(event)
local playgame = event.target
storyboard.gotoScene(“game”, “fade”, 400)
end
–> Add Tap Event for Credits
function showCredits(event)
titleView.isVisible = false
local creditsBG = display.newImage (“creditsScreen.png”)
local creditsBalloonDar = display.newImage (“creditsBalloonDar.png”)
physics.addBody (creditsBalloonDar, “static”, {bounce = 1.5, friction = 10, radius = 45})
creditsBalloonDar.x = display.contentWidth/2 - 95
creditsBalloonDar.y = display.contentHeight/2
local creditsBalloonJay = display.newImage (“creditsBalloonJay.png”)
physics.addBody (creditsBalloonJay, “static”, {bounce = 1.5, friction = 10, radius = 45})
creditsBalloonJay.x = creditsBalloonDar.x + 170
creditsBalloonJay.y = creditsBalloonDar.y + 150
local creditsBalloonCebo = display.newImage (“creditsBalloonCebo.png”)
physics.addBody (creditsBalloonCebo, “static”, {bounce = 1.5, friction = 10, radius = 45})
creditsBalloonCebo.x = creditsBalloonDar.x - 150
creditsBalloonCebo.y = creditsBalloonDar.y + 150
function moveCreditBalloonsDar()
transition.to(creditsBalloonDar, {time=750, speed=0.5, y=math.random(300, 370), onComplete=moveCreditBalloonsDar})
transition.to(creditsBalloonJay, {time=750, speed=0.5, y=math.random(220, 300)})
transition.to(creditsBalloonCebo, {time=750, speed=0.5, y=math.random(220, 300)})
end
moveCreditBalloonsDar()
end
–> Add Event Listeners for Play Game & Credits
playgame:addEventListener(“tap”, startGame)
credits:addEventListener(“tap”, showCredits) [/lua]
Any help would be appreciated.