Problem with Scenes

I’m new to Corona and new to LUA, so please go easy on me. :slight_smile:

OK, so I load a button that takes me to a new screen. Then on the new screen, I have a button that should take me back to the first screen…but does not. Code is below…can anyone tell me what I’m doing wrong?
MAIN.LUA

display.setStatusBar (display.HiddenStatusBar)
local director = require (“director”)

– Create a main group
local mainGroup = display.newGroup()

– Main function
local function main()
mainGroup:insert(director.directorView)
director:changeScene (“mainmenu”)
return true
end
main()
MAINMENU.LUA

module(…, package.seeall)

function new()
local localGroup = display.newGroup()
local ui = require (“ui”)
local tapSound = audio.loadSound( “audio/Press 1.wav” )

local background = display.newImage (“gameback1.png”)
localGroup:insert(background)

local function pressPlay (event)
if event.phase == “ended” then
audio.play( tapSound )
director:changeScene (“loadgame”)
end
end

local playButton = ui.newButton{
defaultSrc = “images/ButtonGray1.png”,
defaultX = 202, defaultY = 32,
overSrc = “images/ButtonCyan1.png”,
overX = 202, overY = 32,
text = “PLAY”,
font = “Helvetica”,
textColor = { 0, 0, 0, 255 },
size = 16,
emboss = false
onRelease = pressPlay
}
playButton.x = 160 playButton.y = 220
localGroup:insert(playButton)

return localGroup
end
LOADGAME.LUA

module(…, package.seeall)

function new()
local localGroup = display.newGroup()
local ui = require(“ui”)
local tapSound = audio.loadSound( “audio/Press 1.wav” )

– BACKGROUND IMAGE
local backgroundImage = display.newImageRect( “blackwhiteback.png”, 320, 480 )
backgroundImage.x = 160; backgroundImage.y = 240
localGroup:insert( backgroundImage )

– local menuBtn
local onMenuTouch = function( event )
if event.phase == “ended” then
audio.play( tapSound )
director:changeScene( “mainmenu” )
end
end

local menuBtn = ui.newButton{
defaultSrc = “images/ButtonGray1.png”, defaultX = 202, defaultY = 32,
overSrc = “images/ButtonCyan1.png”, overX = 202, overY = 32,
id = “MenuButton”,
text = “MENU”, font = “Helvetica”,
textColor = { 0, 0, 0, 255 },
size = 16, emboss = false,
onRelease = onMenuTouch
}

menuBtn.x = 160 menuBtn.y = 250
localGroup:insert( menuBtn )

return localGroup
end [import]uid: 26242 topic_id: 6399 reply_id: 306399[/import]

omg the same thing is happening to me :frowning: [import]uid: 20397 topic_id: 6399 reply_id: 22268[/import]

I would also like to know if the examples in my code are the proper way to make buttons.

I like the idea of using a blank button and letting me code the words onto it, versus creating artwork for 3 or 4 of the same button with different text. [import]uid: 26242 topic_id: 6399 reply_id: 22432[/import]

I use a main menu in my app too, the only thing that I have different is I load the ui in the main.lua file and also I’m not using an event to pass it to the button. Example:
–Menu Button
local function onMenuTouch()
audio.play(buttonClick)
numberofDeals = 0
director:changeScene(“mainmenu”, “downFlip”)
end

–Draw Main Menu Button
local mainMenuButton = ui.newButton{
default = “UpButton.png”, wid = 100, hei = 50,
over = “DownButton.png”, wid = 100, hei = 50,
onRelease = onMenuTouch,
id = “mainMenuButton”,
text = “Main Menu”,
size = 12,
emboss = true}
mainMenuButton.x = screenCenterX * 2 -60
mainMenuButton.y = screenCenterY * 2 - 30
localGroup:insert(mainMenuButton)
I hope this helps. [import]uid: 11809 topic_id: 6399 reply_id: 22443[/import]