# Going from one screen to another

**URL:** <https://forums.solar2d.com/t/going-from-one-screen-to-another/311373>\
**Category:** Uncategorized\
**Created:** [March 11, 2013, 11:13pm UTC](https://forums.solar2d.com/t/going-from-one-screen-to-another/311373 "2013-03-11T23:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmehta97](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@dmehta97](https://forums.solar2d.com/u/dmehta97)\
**Post date:** [March 11, 2013, 11:13pm UTC](https://forums.solar2d.com/t/going-from-one-screen-to-another/311373/1 "2013-03-11T23:13:56Z")

</div>

So I am currently making a game. Its main.lua file is directed, using storyboard to the start.lua file. Here, in the start.lua file, I have it so that when the person presses “play”, it goes to the game.lua file. If the person presses “credits”, then it displays a new background and some images. And I have it so that the main title screen with the play and credits button are not visible using the _titleView.isVisible = false_ command. However, I have been having some trouble going back to the title screen. I tried various things but it just doesn’t work.

Here’s the start.lua file code which contains the code to go to play game or to go to credits screen.

[code] --\> 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) [/code] [import]uid: 234691 topic\_id: 37534 reply\_id: 67534[/import]
