back button doesnt take to previous screen

Okay. Can you show me an example maybe or explain what I need and how the storyboard works, order in which things are suppose to be. [import]uid: 218976 topic_id: 35950 reply_id: 143185[/import]

At a minimum storyboard scene would include this code:

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
function scene:createScene( event )  
 local group = self.view  
  
 -- create your scene here, add your background here, your buttons  
 -- any other display things you want storyboard to move in and out  
 -- of your scene  
 --  
 -- any display object you create should be inserted into group. self.view is a display.newGroup  
 -- i.e.  
 -- background = display.newImageRect("background.png",570,360)  
 -- group:insert(background)  
 --  
 -- If you don't put it into "group", storyboard WILL NOT manage it.  
end  
  
function scene:enterScene( event )  
 local group = self.view  
  
 -- put things in here like starting Runtime listeners, starting animations and timers  
end  
  
function scene:exitScene( event )  
 local group = self.view  
  
 -- stop anything you started in enterScene  
  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
  
 -- you generally don't need to do much here if you put everything in "group" in   
 -- create scene. This might be a good place to dispose of audio loaded in createScene  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

Take a look at the above as your minimum template. [import]uid: 199310 topic_id: 35950 reply_id: 143256[/import]

Thank you for the help [import]uid: 218976 topic_id: 35950 reply_id: 143734[/import]

What I had to do to make that work was before everything was created added etc. Was to assign getPrevious to a variable.

But a little more info would be handy. What happens, do you get an error? If so what error?
Also you say you need help with the code. Where is the code you need help with? [import]uid: 100901 topic_id: 35950 reply_id: 142896[/import]

storyboard.getPrevious() doesn’t take a parameter and returns the previous scene. You may want to do:

storyboard.gotoScene( storyboard.getPrevious() )  

[import]uid: 199310 topic_id: 35950 reply_id: 142946[/import]

there is no error, it just does not do anything
here is the code, i do it with simple items to see how it works first and than i start adding everything else. in my main.lua i have it automatically go to start.lua

local myScene = “start”

and in there i have a button that takes me to scene1.lua

local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene(“scene1”)
end
return true
end

local button1 = display.newRect( 0,0,50,50)
button1:setFillColor( 0, 180, 50)
button1:setReferencePoint(display.CenterReferencePoint)
button1.x = 200
button1.y = 200

button1:addEventListener( “touch”, touchPlay )

and it takes me to the scene1.lua which is below

how would i make the backbutton take me to previous scene?
and if i go to scene2.lua how would i make a button to go to menu scene which is start.lua?

thank you for all the help
[lua]
local storyboard = require “storyboard”
local scene = storyboard.newScene()

local background = display.newRect( 0,0,360,640)
background:setFillColor( 150, 180, 0)
background:setReferencePoint(display.CenterReferencePoint)
background.x = 180
background.y = 320
local box1 = display.newRect( 0,0,50,50)
box1:setReferencePoint(display.CenterReferencePoint)
box1.x = 200
box1.y = 300
local box2 = display.newRect( 0,0,50,50)
box2:setReferencePoint(display.CenterReferencePoint)
box2.x = 100
box2.y = 300
local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene( storyboard.getPrevious() )
end
return true
end
local backbutton = display.newRect( 0,0,50,25)
backbutton:setFillColor( 250, 0, 0)
backbutton:setReferencePoint(display.CenterReferencePoint)
backbutton.x = 60
backbutton.y = 580
backbutton:addEventListener( “touch”, touchPlay )
[lua] [import]uid: 218976 topic_id: 35950 reply_id: 142977[/import]

If you always want the back button to goto start.lua just change it to:

storyboard.gotoScene(“start”)

That’s the simplest way to do that. [import]uid: 199310 topic_id: 35950 reply_id: 143035[/import]

I tried storyboard.gotoScene (“start”) and it still doesnt do anything at all. Its like clicking on nothing. Is there maybe I have to put something in the scene before that to make it work? [import]uid: 218976 topic_id: 35950 reply_id: 143064[/import]

Can you post your full start.lua and the scene where you are trying to setup your button.

Please enclose the code inside of <code> and </code> tags.

[import]uid: 199310 topic_id: 35950 reply_id: 143066[/import]

here is the start.lua code

[code]local storyboard = require “storyboard”

local scene = storyboard.newScene()

local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene(“scene1”)
end
return true
end

local button1 = display.newRect( 0,0,50,50)
button1:setFillColor( 0, 180, 50)
button1:setReferencePoint(display.CenterReferencePoint)
button1.x = 200
button1.y = 200

button1:addEventListener( “touch”, touchPlay )
[/code]
and here is scene1.lua

[code]local storyboard = require “storyboard”

local scene = storyboard.newScene()

local start = storyboard.getPrevious()

local background = display.newRect( 0,0,360,640)
background:setFillColor( 150, 180, 0)
background:setReferencePoint(display.CenterReferencePoint)
background.x = 180
background.y = 320

local box1 = display.newRect( 0,0,50,50)
box1:setReferencePoint(display.CenterReferencePoint)
box1.x = 200
box1.y = 300

local box2 = display.newRect( 0,0,50,50)
box2:setReferencePoint(display.CenterReferencePoint)
box2.x = 100
box2.y = 300

local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene(“start”)
end
return true
end

local back = display.newRect( 0,0,50,25)
back:setFillColor( 250, 0, 0)
back:setReferencePoint(display.CenterReferencePoint)
back.x = 60
back.y = 580

back:addEventListener( “touch”, touchPlay ) [import]uid: 218976 topic_id: 35950 reply_id: 143071[/import]

Neither of those lua files are storyboard scenes. They are missing the required event handlers for createScene, enterScene, exitScene, etc and you are never adding any thing to the scene 's view group for storyboard to manage.

[import]uid: 199310 topic_id: 35950 reply_id: 143128[/import]

Okay. Can you show me an example maybe or explain what I need and how the storyboard works, order in which things are suppose to be. [import]uid: 218976 topic_id: 35950 reply_id: 143185[/import]

At a minimum storyboard scene would include this code:

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
function scene:createScene( event )  
 local group = self.view  
  
 -- create your scene here, add your background here, your buttons  
 -- any other display things you want storyboard to move in and out  
 -- of your scene  
 --  
 -- any display object you create should be inserted into group. self.view is a display.newGroup  
 -- i.e.  
 -- background = display.newImageRect("background.png",570,360)  
 -- group:insert(background)  
 --  
 -- If you don't put it into "group", storyboard WILL NOT manage it.  
end  
  
function scene:enterScene( event )  
 local group = self.view  
  
 -- put things in here like starting Runtime listeners, starting animations and timers  
end  
  
function scene:exitScene( event )  
 local group = self.view  
  
 -- stop anything you started in enterScene  
  
end  
  
function scene:destroyScene( event )  
 local group = self.view  
  
 -- you generally don't need to do much here if you put everything in "group" in   
 -- create scene. This might be a good place to dispose of audio loaded in createScene  
end  
  
scene:addEventListener( "createScene", scene )  
scene:addEventListener( "enterScene", scene )  
scene:addEventListener( "exitScene", scene )  
scene:addEventListener( "destroyScene", scene )  
  
return scene  

Take a look at the above as your minimum template. [import]uid: 199310 topic_id: 35950 reply_id: 143256[/import]

Thank you for the help [import]uid: 218976 topic_id: 35950 reply_id: 143734[/import]

What I had to do to make that work was before everything was created added etc. Was to assign getPrevious to a variable.

But a little more info would be handy. What happens, do you get an error? If so what error?
Also you say you need help with the code. Where is the code you need help with? [import]uid: 100901 topic_id: 35950 reply_id: 142896[/import]

storyboard.getPrevious() doesn’t take a parameter and returns the previous scene. You may want to do:

storyboard.gotoScene( storyboard.getPrevious() )  

[import]uid: 199310 topic_id: 35950 reply_id: 142946[/import]

there is no error, it just does not do anything
here is the code, i do it with simple items to see how it works first and than i start adding everything else. in my main.lua i have it automatically go to start.lua

local myScene = “start”

and in there i have a button that takes me to scene1.lua

local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene(“scene1”)
end
return true
end

local button1 = display.newRect( 0,0,50,50)
button1:setFillColor( 0, 180, 50)
button1:setReferencePoint(display.CenterReferencePoint)
button1.x = 200
button1.y = 200

button1:addEventListener( “touch”, touchPlay )

and it takes me to the scene1.lua which is below

how would i make the backbutton take me to previous scene?
and if i go to scene2.lua how would i make a button to go to menu scene which is start.lua?

thank you for all the help
[lua]
local storyboard = require “storyboard”
local scene = storyboard.newScene()

local background = display.newRect( 0,0,360,640)
background:setFillColor( 150, 180, 0)
background:setReferencePoint(display.CenterReferencePoint)
background.x = 180
background.y = 320
local box1 = display.newRect( 0,0,50,50)
box1:setReferencePoint(display.CenterReferencePoint)
box1.x = 200
box1.y = 300
local box2 = display.newRect( 0,0,50,50)
box2:setReferencePoint(display.CenterReferencePoint)
box2.x = 100
box2.y = 300
local function touchPlay( event )
if event.phase == “began” then
storyboard.gotoScene( storyboard.getPrevious() )
end
return true
end
local backbutton = display.newRect( 0,0,50,25)
backbutton:setFillColor( 250, 0, 0)
backbutton:setReferencePoint(display.CenterReferencePoint)
backbutton.x = 60
backbutton.y = 580
backbutton:addEventListener( “touch”, touchPlay )
[lua] [import]uid: 218976 topic_id: 35950 reply_id: 142977[/import]

If you always want the back button to goto start.lua just change it to:

storyboard.gotoScene(“start”)

That’s the simplest way to do that. [import]uid: 199310 topic_id: 35950 reply_id: 143035[/import]

I tried storyboard.gotoScene (“start”) and it still doesnt do anything at all. Its like clicking on nothing. Is there maybe I have to put something in the scene before that to make it work? [import]uid: 218976 topic_id: 35950 reply_id: 143064[/import]

Can you post your full start.lua and the scene where you are trying to setup your button.

Please enclose the code inside of <code> and </code> tags.

[import]uid: 199310 topic_id: 35950 reply_id: 143066[/import]