Yes, you need to have the pagelist located in the main.lua file
I have been trying to do that myself. It is simple to add the button, like so and the event listener, but it crashes.
in pages.lua
//button image
local button\_home = display.newImageRect("res/images/button\_home.png", 53, 53);
button\_home:setReferencePoint(display.CenterReferencePoint);
button\_home.x = 50; button\_home.y = 30;
button\_home.scene = "menu";
localGroup:insert(button\_home);
//listener function
function changeScene(e)
if(e.phase == "ended") then
director:changeScene( (e.target.scene, "crossfade" );
end
end
//bind the listener to button
button\_home:addEventListener("touch", changeScene);
Again, that is what i have, but the director:changeScene crashes things. You can use the other function to go to any page, but you cannot leave the book. Hope this gives you a start, from here, i guess its just trial and error for us until we find the code to change back to the main menu scene.
Updated…
Here is the working code
//button image
local button\_home = display.newImageRect("res/images/button\_home.png", 53, 53);
button\_home:setReferencePoint(display.CenterReferencePoint);
button\_home.x = 50; button\_home.y = 30;
button\_home.scene = "menu";
localGroup:insert(button\_home);
//listener function
function changeScene(e)
if(e.phase == "ended") then
director:turnToScenes()
--director:changeScene("menu", "crossfade" ); -- Back to Menu
director:changeScene(e.target.scene, "crossfade" ); -- Button\_Defined Scene
-- Just uncomment which one you want to use
end
end
//bind the listener to button
button\_home:addEventListener("touch", changeScene);
Hope this helps! [import]uid: 75514 topic_id: 23982 reply_id: 96956[/import]