There’s A few things I’ve noticed , the menu button works on the Samsung galaxy s3 but not on the s5 , and also the button will change to a different scene but not the scene it was previously on does that make a difference ?
Please don’t dump your entire module in a post unless you’ve specifically been asked to. Just post the code relevant to the problem at hand. In this case, the code involving your back button.
Please use the <> button in the button bar in the same row as B I U S X2 X2 and so on. Click that button and paste your code in the box that shows up.
Rob
sorry some people said it was how i set out my groups so i thought you needed the whole code , because the button works , because if i change the scene to a scene i havnt entered yet for example a different game mode ive not yet played , it changes but because ive just come from the menu it wont let me go back to the menu ,
but here is the menu button
function loadScore( event ) if event.phase == "ended" then storyboard.gotoScene("menu", "fade"); end return true end
saveButton = widget.newButton({ width = 200, height = 64, x = display.contentCenterX, y = display.contentHeight - 64, label = "Load Score", labelColor = { default = { 1, 1, 1 }, over = { 0, 0, 0 } }, fontSize = 32, font = "Pacifico", onEvent = loadScore })
the load score function is before the other one but it pasted in here the wrong way round ,
---->gameHard
my game goes like this----- main---->menu---->gameNormal , then if the menu button is pressed it goes back to the menu
---->gameEasy
so when i press the menu button on one of the game modes , it wont back to the menu because it was the scene it just came from
is there a fix for this ? , would changing to composer fix this
also the game works perfect on a samsung galaxy s3 but not on the new s5
Well your code looks about right. But you might want to try:
function loadScore( event ) if event.phase == "ended" then storyboard.removeScene("menu") storyboard.gotoScene("menu", "fade"); end return true end
Ok I will try it now , also would using a cut scene help ? For example go from menu---->cutscene----> game—>cutscene2---->menu. And so on ?, do you think that would sort the problem I’m having ?
Bump
Cut scenes are helpful, but perhaps in your menu.lua, just before you call composer.gotoScene(“game1”) call composer.removeScene(“game1”) if you always want a fresh restart. It’s okay to call removeScene if the scene has never been gone to in the first place.
Rob
I’ve done the changes you said and it hadn’t changed ?
Is there any other reason it could happen ?
Can you restate your problem? Perhaps some screen shots or a video demoing the issue?
Rob
The problem is that my game is set up like this main.lua----> menu.lua-----> (then you select a game mode) —>gameHard -->gameEasy---->the back to menu but it won’t change to menu cause I was just on the menu
But it will change to another game mode from the game mode it’s currents on if you get me
Let me try this again. In menu.lua just before you call composer.gotoScene() call composer.removeScene() with the same scene name. For example:
composer.removeScene(“somescene”)
composer.gotoScene(“somescene”)
So from menu if you’re going to gameEasy call those two lines. When you are going back to your menu, use “menu” in both lines.