Hi,
I am learning to use the storyboard which does not look hard at all. But I am trying to add a touch event which I copied from the scene1 code of the online sample at the following URL. The image shows of mine but it does not print when I touch the screen. Does anyone see anything wrong here?
https://github.com/ansca/Storyboard-Sample/blob/master/scene1.lua
Thanks!!
----------------------------------------------------------------------------------
--
-- scenetemplate.lua
--
----------------------------------------------------------------------------------
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
-- Touch event listener for background image
local function onSceneTouch( self, event )
if event.phase == "began" then
print("Screen touched!")
storyboard.gotoScene( "SceneEvents", "fade", 400 )
return true
end
end
----------------------------------------------------------------------------------
--
-- NOTE:
--
-- Code outside of listener functions (below) will only be executed once,
-- unless storyboard.removeScene() is called.
--
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
-- Called when the scene's view does not exist:
function scene:createScene( event )
local screenGroup = self.view
imgHome = display.newImage( "HomePage.jpg" )
screenGroup:insert( imgHome )
-- position the image
imgHome:translate( 0,0 )
imgHome.touch = onSceneTouch
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
local group = self.view
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 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: 184193 topic_id: 32990 reply_id: 332990[/import]