Start game button

I don’t want my game to start when the app is launched. I want it to start when they press a “Start” button.

My game is working well and is all coded in a mail.lua file.

How do I make this “Start” button trigger the game to start?

Hope that makes sense and thanks in advanced for any help. [import]uid: 56508 topic_id: 10837 reply_id: 310837[/import]

Hi

I am new to Corona but given the lack of responses, I think this is what you need.

On your main.lua file use “splash” at the change scene line.

Create a new .lua file (call it splash.lua) and then use this code changing image, button name/position etc to suit yourself. Then copy this code into the splash.lua and save it.

module(…, package.seeall)

function new()
local localGroup = display.newGroup()
–> This is how we start every single file or “screen” in our folder, except for main.lua
– and director.lua
–> director.lua is NEVER modified, while only one line in main.lua changes, described in that file


local background = display.newImage (“splash.png”)
localGroup:insert(background)
–> This sets the background

local menubutton = display.newImage (“menubutton.png”)
menubutton.x = 259
menubutton.y = 315
localGroup:insert(menubutton)

local function pressMenu (event)
if event.phase == “ended” then
director:changeScene (“menu2”)
end
end

menubutton:addEventListener (“touch”, pressMenu)
return localGroup
end

When your app is launched it will open up your 'splash ’ page with your button. The button and the scene change should then direct you to your play.lua.

Hope this helps. [import]uid: 45029 topic_id: 10837 reply_id: 39439[/import]

Hey guys,

I’m flattered! Bob, your code is from one of my tutorials :slight_smile:

On that note; tgildesign, check out this tutorial, it’s the original, in full and will show you how to easily do what you want with a start button :slight_smile:

http://techority.com/2010/11/19/how-to-use-scenesscreens-in-corona/

Peach :slight_smile: [import]uid: 52491 topic_id: 10837 reply_id: 39451[/import]

Hi Peach

As someone who is totally new to any kind of coding (not just Corona), my apps are being built using 90% tips/good advice/knowledge from yourself and Graham Ranson and 10% of my trial and error/fumbling around (but I am absolutely loving it!)

Great resource to have on tap. Thanks

Bob [import]uid: 45029 topic_id: 10837 reply_id: 39454[/import]

Peach , bob8, thanks so much. I will tinker with this right now! [import]uid: 56508 topic_id: 10837 reply_id: 39460[/import]