–
–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>