Scene touch event not working when returning to scene

Hi,

I have a project with scenes and one scene1 I have a function called onSceneTouch that works and takes me to scene2. When I return to scene1 by saying storyboard.gotoScene( “Scene1”, “fade”, 300 ) it takes me back but the function onSceneTouch is not working.

I am adding the event here in Scene1. What am I doing wrong? Thanks!

function scene:enterScene( event )  
  
 storyboard.purgeScene( "sceneHome" )  
 storyboard.purgeScene( "scene2" )  
  
 -- Update Lua memory text display  
 local showMem = function()  
 imgHeader:addEventListener( "touch", imgHeader )  
 end  
 local memTimer = timer.performWithDelay( 1000, showMem, 1 )  
end  

[import]uid: 184193 topic_id: 33987 reply_id: 333987[/import]

  1. You’ve capitalized “Scene1”, which would cause the command not to work

  2. Is there any sort of error message?

  3. You’re attaching a listener to imgHeader, not the scene. Is imgHeader in the scene display group?

  4. Just a personal recommendation but you might find it easier to work with a flag check.

function imgHeader:touch(event) if self.ready then storyboard.gotoScene("scene1", "fade", 300) end end -- self.ready = imgHeader.ready

You could then use the timer to set imgHeader.ready = true, which gives you an easy way to toggle it on/off in enterScene/exitScene.
[import]uid: 41884 topic_id: 33987 reply_id: 135110[/import]

Thanks. I just renamed the scenes for reference in here. Is there any way I can send you a private email so my code is not so public?

Thanks!

Warren
[import]uid: 184193 topic_id: 33987 reply_id: 135119[/import]

[import]uid: 41884 topic_id: 33987 reply_id: 135123[/import]

I just emailed you to make sure you got the files attached.

Thanks!
[import]uid: 184193 topic_id: 33987 reply_id: 135159[/import]

  1. You’ve capitalized “Scene1”, which would cause the command not to work

  2. Is there any sort of error message?

  3. You’re attaching a listener to imgHeader, not the scene. Is imgHeader in the scene display group?

  4. Just a personal recommendation but you might find it easier to work with a flag check.

function imgHeader:touch(event) if self.ready then storyboard.gotoScene("scene1", "fade", 300) end end -- self.ready = imgHeader.ready

You could then use the timer to set imgHeader.ready = true, which gives you an easy way to toggle it on/off in enterScene/exitScene.
[import]uid: 41884 topic_id: 33987 reply_id: 135110[/import]

Thanks. I just renamed the scenes for reference in here. Is there any way I can send you a private email so my code is not so public?

Thanks!

Warren
[import]uid: 184193 topic_id: 33987 reply_id: 135119[/import]

[import]uid: 41884 topic_id: 33987 reply_id: 135123[/import]

I just emailed you to make sure you got the files attached.

Thanks!
[import]uid: 184193 topic_id: 33987 reply_id: 135159[/import]