2 questions



–level1.lua

[code]local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

– include Corona’s “widget” library
local widget = require “widget”

– ‘onRelease’ event listener for playBtn
local function onPlayBtnRelease()
–print(“goto scene”)
– go to level2.lua scene
storyboard.gotoScene( “level2”)

return true – indicates successful touch
end

– BEGINNING OF YOUR IMPLEMENTATION

– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.


local background = display.newRect(0,0,display.contentWidth,display.contentHeight)
background:setFillColor(0,0,0)

– include Corona’s “widget” library
–local widget = require “widget”
– forward declarations and other locals
–local playBtn

– include Corona’s “widget” library
local widget = require “widget”

– ‘onRelease’ event listener for playBtn
local function onPlayBtnRelease()
–print(“goto scene”)
– go to level2.lua scene
storyboard.gotoScene( “level2”)

return true – indicates successful touch
end

– create a widget button (which will loads level1.lua on release)
playBtn = widget.newButton{
– label=“Schedule a Text”,
label=“Go Back”,
labelColor = { default={255}, over={128} },
default=“button.png”,
over=“button-over.png”,
width=100, height=40,
onRelease = (goBack ) – event listener function

}
–end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view

– INSERT code here (e.g. start timers, load audio, start listeners, etc.)

end

– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view

– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)

end

– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view

if playBtn then
playBtn:removeSelf() – widgets must be manually removed
playBtn = nil
end
end

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view

– create a grey rectangle as the backdrop
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 255 )
group:insert(bg)
bg.x = display.contentWidth * 0.5;
bg.y = display.contentHeight * 0.5;

local font = native.systemFont;
–end

local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
–columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)
columnData[2] = {}
columnData[2].alignment = “center”
for i=1,31 do
columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex

local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=50,
columns=columnData
}
local widget = require “widget”
widget.setTheme (“theme_ios”)

– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)
columnData[2] = { “00”}
columnData[2].alignment = “center”
for i= 1,59 do
columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1

– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}

local label = display.newText(“with the understanding”, 0, 0, font, 18) ;
–label:setReferencePoint(display.CenterReferencePoint);
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .95;

function label:tap(e)
native.showAlert(“Tapped”,“with the understanding!”,{“Ok”})
native.showPopup(“sms”,{
–body = “I sent this text from my app”,
–to = {“5550000000”} – or “5550000000” if this doesn’t work
}) ;
end

label:addEventListener(“tap”, label);

system.vibrate()

end

function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min

segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)

if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end

if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end

back = os.date( “!*t”, os.time() + seg_reg )
return back


end



-----------------------------------------------------------------------------------------
– END OF YOUR IMPLEMENTATION
-----------------------------------------------------------------------------------------

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched whenever before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )

-----------------------------------------------------------------------------------------

[/code]return scene

So here is full file. I didn’t add an eventlistener because for all of my other buttons I used: local function onPlayBtnRelease()
--print(“goto scene”)
– go to level2.lua scene
storyboard.gotoScene( “level2”)
and it worked. I understand your question but I dont understand why what I did for my other buttons is not working on the goBack button.
[import]uid: 69302 topic_id: 30745 reply_id: 123145[/import] </segundos_in>

When you declare the button your onRelease parameter is an eventListener you are adding.

Regardless of whatever is going on you need to make sure your button’s onRelease parameter points to whatever function is going to handle your going back a scene code. [import]uid: 147305 topic_id: 30745 reply_id: 123146[/import]

So line 54 is not telling it what to do? [import]uid: 69302 topic_id: 30745 reply_id: 123148[/import]

yes baby, I think budersbank is saying that instead of saying:

onRelease = (goBack )

it should instead say:

onRelease = onPlayBtnRelease


The onRelease parameter is supposed to be a pointer to the function you want called when the button is released. Your parameter (goBack) is not defined anywhere in the module, so would be set to nil (probably) when the button was created. If it is nil, then I would expect nothing would get called when the button is released.

Well, that’s my two cents anyways.
[import]uid: 79933 topic_id: 30745 reply_id: 123150[/import]

No mpappas, i encourage all input. :slight_smile: See what I dont get is that I originally had onRelease = onPlayBtnRelease but it didnt work. so that is when I posted this question. I only changed it to see what could be done to fix it. [import]uid: 69302 topic_id: 30745 reply_id: 123153[/import]

I put it back to what both of you all suggested but it still will not go back. I am going to keep playing with it because I am determined to get this button to go back! [import]uid: 69302 topic_id: 30745 reply_id: 123155[/import]

Ok Budershank,
I tried testing your code and even that is not switching the scene back. So what am I missing? Your back button is doing the same thing mine did. It is acknowledging it was touched by blinking but not doing the event(going back) And I did change your mainmenu scene to my scene ? [import]uid: 69302 topic_id: 30745 reply_id: 123158[/import]

post the code for your button and your event function i guess. [import]uid: 147305 topic_id: 30745 reply_id: 123159[/import]

Sorry and thank you. I have been trying and trying. Looking a examples from the learning corona videos and nothing. I think what is most frustrating is that I have this exact same button on two other screens and it does exactly what I asked it to do. So this is what I have in reference to the button.

[code]
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

– include Corona’s “widget” library
local widget = require “widget”

– forward declarations and other locals
local playBtn

– ‘onRelease’ event listener for playBtn
local function onPlayBtnRelease()
storyboard.gotoScene( “level2”)

return true – indicates successful touch

end


– BEGINNING OF YOUR IMPLEMENTATION

– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.


local background = display.newRect(0,0,display.contentWidth,display.contentHeight)
background:setFillColor(0,0,0)

– create a widget button (which will loads level1.lua on release)
playBtn = widget.newButton{
label=“Go Back”,
labelColor = { default={255}, over={120} },
default=“button.png”,
over=“button-over.png”,
width=100, height=40,
onRelease = onPlayBtnRelease – event listener function

}

[/code] [import]uid: 69302 topic_id: 30745 reply_id: 123160[/import]

Is this code coming from lua file called scene2? [import]uid: 147305 topic_id: 30745 reply_id: 123180[/import]

No, I don’t have a file called scene 2. my file is called level 2. And again, its the same way I have named my other files and they worked. Are you implying that I should rename it to scene2? [import]uid: 69302 topic_id: 30745 reply_id: 123183[/import]

No, my mistake on scene2. I meant level2.

Are you trying to switch to level2 scene from inside the level2 scene? That doesn’t really work. [import]uid: 147305 topic_id: 30745 reply_id: 123184[/import]

Okay let me start over. I renamed the scenes because even I was getting confused. I want scene2 to go back to scene1 when user presses the back button. this same button changes scene(move to the next scene) but it will not go backwards.

[code] --scene2.lua

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

– include Corona’s “widget” library
local widget = require “widget”

– forward declarations and other locals
local playBtn

– ‘onRelease’ event listener for playBtn
local function onPlayBtnRelease()
storyboard.gotoScene( “scene1”)

return true – indicates successful touch

end


– BEGINNING OF YOUR IMPLEMENTATION

– NOTE: Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.


local background = display.newRect(0,0,display.contentWidth,display.contentHeight)
background:setFillColor(0,0,0)

– create a widget button (which will loads level1.lua on release)
playBtn = widget.newButton{
label=“Go Back”,
labelColor = { default={255}, over={120} },
default=“button.png”,
over=“button-over.png”,
width=100, height=40,
onRelease = onPlayBtnRelease – event listener function

}

–end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view

– INSERT code here (e.g. start timers, load audio, start listeners, etc.)

end

– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view

– INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)

end

– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view

if playBtn then
playBtn:removeSelf() – widgets must be manually removed
playBtn = nil
end
end

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view

– create a grey rectangle as the backdrop
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg:setFillColor( 255 )
group:insert(bg)
bg.x = display.contentWidth * 0.5;
bg.y = display.contentHeight * 0.5;

local font = native.systemFont;
–end

local widget = require “widget”
widget.setTheme (“theme_ios”)
– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December” }
–columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)
columnData[2] = {}
columnData[2].alignment = “center”
for i=1,31 do
columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = {}
for i=1,25 do
columnData[3][i] = i+2011
end
columnData[3].startIndex = yearIndex

local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=50,
columns=columnData
}
local widget = require “widget”
widget.setTheme (“theme_ios”)

– create table to hold all column data
local columnData = {}

– create first column
columnData[1] = { “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “11”, “12” }
columnData[1].alignment = “right”
columnData[1].width = 120
columnData[1].startIndex = 1

– second column (lots of rows)
columnData[2] = { “00”}
columnData[2].alignment = “center”
for i= 1,59 do
columnData[2][i] = i
end
columnData[2].startIndex = 1

– third column
columnData[3] = { “AM”, “PM” }
columnData[3].startIndex = 1

– create the actual picker widget with column data
local picker = widget.newPickerWheel{
id=“myPicker”,
font=“Helvetica-Bold”,
top=200,
columns=columnData
}

local label = display.newText(“with the understanding”, 0, 0, font, 18) ;
–label:setReferencePoint(display.CenterReferencePoint);
label:setReferencePoint(display.BottomCenterReferencePoint);
label:setTextColor(255, 255, 255) ;
label.x = display.contentWidth * 0.5;
label.y = display.contentHeight * .95;

function label:tap(e)
native.showAlert(“Tapped”,“with the understanding!”,{“Ok”})
native.showPopup(“sms”,{
–body = “I sent this text from my app”,
–to = {“5550000000”} – or “5550000000” if this doesn’t work
}) ;
end

label:addEventListener(“tap”, label);

system.vibrate()

end

function time_to_notify(hora_in, minutos_in)
local utcTime = os.date( “!*t”, os.time() )
local timeTable = os.date("*t")
local hora_cl = timeTable.hour
local minuto_cl = timeTable.min

segundos_cl = (hora_cl*60*60)+(minuto_cl*60)
segundos_in = (hora_in*60*60)+(minutos_in*60)

if(segundos_cl>segundos_in)then
seg_reg = 86400 - segundos_cl + segundos_in
end

if(segundos_cl<segundos_in> seg_reg = segundos_in-segundos_cl
end

back = os.date( “!*t”, os.time() + seg_reg )
return back

[/code]end [import]uid: 69302 topic_id: 30745 reply_id: 123185[/import] </segundos_in>

So Im still having issues with this button. I got the button on scene1 when pressed go to scene2 and I have the button on scene2 when pressed to go back to scene1 but the button in scene1 now will not go to scene2 a second time. why is that? [import]uid: 69302 topic_id: 30745 reply_id: 124445[/import]

So Im still having issues with this button. I got the button on scene1 when pressed go to scene2 and I have the button on scene2 when pressed to go back to scene1 but the button in scene1 now will not go to scene2 a second time. why is that? [import]uid: 69302 topic_id: 30745 reply_id: 124445[/import]