videotuts.lua
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local content = require("content")
-- Setup a scrollable content group
scrollNav = require("scrollNav")
scrollNav = scrollNav.new({left=0, right=0, tm=topMargin, lm=leftMargin, sp=spacing})
-- Iterate through content and add to scrollNav
for index, value in ipairs(content) do
local thumb = display.newImage(content[index].thumb)
scrollNav:insertButton(thumb, content[index].asset)
end
--import the scrollNav class
local backgroundWidth, backgroundHeight, backgroundAlignment, spacing, leftMargin, topMargin, scrollbarY, content, scrollNav
-- Touch event listener for background image
local function onSceneTouch( self, event )
if event.phase == "began" then
storyboard.gotoScene( "scene1", "slideLeft", 800 )
return true
end
end
-- Called when the scene's view does not exist:
function scene:createScene( event )
local screenGroup = self.view
buttonWeather = display.newImage( "weatherbutton.png", 100,700 )
buttonWeather.touch = onSceneTouch
screenGroup:insert( buttonWeather )
text1 = display.newText( "Scene 1", 0, 0, native.systemFontBold, 24 )
text1:setTextColor( 255 )
text1:setReferencePoint( display.CenterReferencePoint )
text1.x, text1.y = display.contentWidth \* 0.5, 50
screenGroup:insert( text1 )
-- Background Width/Height/Alignment
backgroundWidth = 640
backgroundHeight = 1136
backgroundAlignment = "center"
-- Scroll Nav spacing/margins
spacing = 50
leftMargin = 50
topMargin = 300
scrollbarY = 680
-- Load content
scrollNav = scrollNav.new({left=0, right=0, tm=topMargin, lm=leftMargin, sp=spacing})
-- Add the scrollbar to the scrollNav
scrollNav:addScrollBar(scrollbarY)
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
print( "1: enterScene event" )
-- remove previous scene's view
storyboard.purgeScene( "scene4" )
-- Update Lua memory text display
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
print( "1: exitScene event" )
-- remove touch listener for image
buttonWeather2:removeEventListener( "touch", buttonWeather2 )
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
print( "((destroying scene 1's view))" )
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene2", scene )
-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )
-- "exitScene" event is dispatched 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 )
return scene
[import]uid: 88495 topic_id: 34875 reply_id: 138648[/import]