Can't get the Touch to work in my screne

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]

Hmmm… this line…

imgHome.touch = onSceneTouch

This is not a touch listener. You’re only appending a “property” to “imgHome” that equals (as a pointer) the function “onSceneTouch”. This doesn’t create any touch functionality. You need to add a touch listener to your image with the target function (listener function) as “onSceneTouch”.

Hope this helps!
Brent Sorrentino [import]uid: 9747 topic_id: 32990 reply_id: 131027[/import]

Hmmm… this line…

imgHome.touch = onSceneTouch

This is not a touch listener. You’re only appending a “property” to “imgHome” that equals (as a pointer) the function “onSceneTouch”. This doesn’t create any touch functionality. You need to add a touch listener to your image with the target function (listener function) as “onSceneTouch”.

Hope this helps!
Brent Sorrentino [import]uid: 9747 topic_id: 32990 reply_id: 131027[/import]

Thanks! I compared my code to the one posted on here in a blog and noticed where I was missing some stuff and the same as what you mentioned. So it is fixed now!

Now that I can accomplish what I wanted with Corona SDK I plan to subscribe this weekend.

Warren
[import]uid: 184193 topic_id: 32990 reply_id: 131065[/import]

Thanks! I compared my code to the one posted on here in a blog and noticed where I was missing some stuff and the same as what you mentioned. So it is fixed now!

Now that I can accomplish what I wanted with Corona SDK I plan to subscribe this weekend.

Warren
[import]uid: 184193 topic_id: 32990 reply_id: 131065[/import]