How Do I Change the Scene?

Hi there. I’m having trouble making the option clickable and changing the scene. I have a menu.lua file that has two options, and if a user clicks on one of them it will send him to a separate lua file. What are some suggestions I could have to make the option clickable to go to a different scene?

[lua]function scene:enterScene (event)
local group = self.view

end
[import]uid: 162639 topic_id: 29725 reply_id: 329725[/import]

Not sure what your example code is all about…

I think your best bet would to be make a new project and choose the “Game” option. It gives you an example of having a main menu that uses storyboard. I actually use that a lot as a starter template. [import]uid: 147305 topic_id: 29725 reply_id: 119346[/import]

storyboard.gotoScene(‘differentScene’) [import]uid: 75779 topic_id: 29725 reply_id: 119349[/import]

Thank you for giving me your input; however, after using your suggestions I found I still have a problem. I have a menu.lua file that has two options, and when a person clicks on one of the options it would send him to a separate lua file. Could you please give me some advice?
[lua]function scene:createScene (event)
local group = self.view

– This is to display the option on the screen.
local pianoBtn = display.newImage( “button_piano.PNG”, 0, 0)
pianoBtn.x = display.contentWidth / 2
pianoBtn.y = display.contentWidth / 0.9
–Once the option is displayed, it needs
–to be clickable. When a user clicks on the option, it’ll send him to the
–next scene, which is a separate lua file.

end

function scene:enterScene (event)
local group = self.view
storyboard.gotoScene( “piano”, “fade”, 400 )
–This space is for the code that should
–make the option clickable.

end[/lua] [import]uid: 162639 topic_id: 29725 reply_id: 119363[/import]

Okay you need a touch listener on the piano button that will send you to a function that calls the storyboard.gotoScene( “piano”, “fade”, 400 )
something like this:
[lua]function scene:createScene (event)
local group = self.view

– This is to display the button on the screen.
local pianoBtn = display.newImage( “button_piano.PNG”, 0, 0)
pianoBtn.x = display.contentWidth / 2
pianoBtn.y = display.contentWidth / 0.9
–Once the button is displayed, they need
–to ba clickable. When a user clicks on the button, it’ll send him to the
–next scene, which is a separate lua file.

end

function scene:enterScene (event)
local group = self.view
function changeScene()
storyboard.gotoScene( “piano”, “fade”, 400 )
end
pianoBtn:addEventListener(‘touch’, changScene)
–This space is for the code that should
–make the button clockable. Without it, the
–button will be useless.

end[/lua]
[import]uid: 75779 topic_id: 29725 reply_id: 119365[/import]

Thank you giving me more of the input; however, after using the piece of code the option doesn’t seem to respond at the moment. Could you please give me a little more advice?

Also, what is there to add to the scene:exitScene and scene:destroyScene functions? [import]uid: 162639 topic_id: 29725 reply_id: 119372[/import]

Hmm could be multiple things, did you start with a main.lua file then send it to menu.lua. did you require storyboard.

Also, what is there to add to the scene:exitScene and scene:destroyScene functions? Not much but they will clean your scene for the next one

Just noticed you need to put pianoBtn into a group like so:
group:insert(pianoBtn) [import]uid: 75779 topic_id: 29725 reply_id: 119433[/import]