create a game menu

Hi, I’ve created the main menu for my game, the problem is that I don’ t know how can I change the Scene, Here’s the code I’ve used:

local \_H = display.contentHeight;  
local \_W = display.contentWidth;  
  
display.setStatusBar(display.HiddenStatusBar);  
  
local intromusic = audio.loadStream( "music.mp3" , true)  
 local playThatFunkyMusic = function()  
 audio.play( intromusic, { channel=12, loops=-1 } )  
 end  
 local playIntroMusic = timer.performWithDelay(1, playThatFunkyMusic, 1)  
  
local background = display.newImage("images/background.jpg");  
background:setReferencePoint(display.CenterReferencePoint);  
background.x=\_W/2; background.y=\_H/2;  
local titolo = display.newText("Game",0,0,native.systemFont, 70);  
titolo:setReferencePoint(display.CenterReferencePoint);  
titolo.x=\_W/2; titolo.y=80;  
  
local titolo = display.newText("Title",0,0,native.systemFont, 70);  
titolo:setReferencePoint(display.CenterReferencePoint);  
titolo.x=\_W/2; titolo.y=150;  
  
local button1 = display.newImage("images/button1.png");  
button1:setReferencePoint(display.CenterReferencePoint);  
button1.x=\_W/2; button1.y=260;  
button1.xScale=0.3; button1.yScale=0.2;  
button1:setFillColor(255,255,0);  
button1.alpha=0.7;  
  
local button2 = display.newImage("images/button2.png");  
button2:setReferencePoint(display.CenterReferencePoint);  
button2.x=\_W/2; button2.y=330;  
button2.xScale=0.3; button2.yScale=0.2;  
button2:setFillColor(255,255,0);  
button2.alpha=0.7;  
  
local button3 = display.newImage("images/button3.png");  
button3:setReferencePoint(display.CenterReferencePoint);  
button3.x=\_W/2; button3.y=400;  
button3.xScale=0.3; button3.yScale=0.2;  
button3:setFillColor(255,255,0);  
button3.alpha=0.7;  
  
local ciao = display.newImage("images/Default.png");  
ciao:setReferencePoint(display.CenterReferencePoint);  
transition.to(ciao, {time=3000, alpha=0.0});  
  
function button1:touch(a)  
 mainGroup:insert(director.directorView);  
 if a.phase == "ended" then  
 director:changeScene("gameScreen");  
 return true;  
 end  
end  
  
button1:addEventListener("touch", button1);  
  
function button2:touch(b)  
 if b.phase == "began" then  
 director:changeScene("Credits");  
  
 end  
end  
  
button2:addEventListener("touch", button2);  
  
function button3:touch(c)  
 if c.phase == "began" then  
  
 os.exit(1);  
 end  
end  
  
button3:addEventListener("touch",button3);  
  
localGroup:insert(button1);  
localGroup:insert(button2);  
localGroup:insert(button3);  

How can I add them? Thanks [import]uid: 129238 topic_id: 23466 reply_id: 323466[/import]

You would really want to use something like Storyboard for switching between scenes.
Storyboard

There’s also a template here you can check out.

Here are the FAQ that explain storyboard in more detail also. [import]uid: 54776 topic_id: 23466 reply_id: 94092[/import]

Hey, saw you made two posts, know it wasn’t deliberate and am leaving both us as both have good answers on them but please try to only click the post button once in future :wink:

Thanks,
Peach :slight_smile: [import]uid: 52491 topic_id: 23466 reply_id: 94228[/import]

Yes, I did a mistake sorry xD, anyway, I solved my problems, thank you so much! :wink: [import]uid: 76800 topic_id: 23466 reply_id: 96937[/import]

Yes, I did a mistake sorry xD, anyway, I solved my problems, thank you so much! :wink: [import]uid: 76800 topic_id: 23466 reply_id: 96938[/import]