Storyboard fails after 3 clicks?

Hello!

I got a weird situation with Storyboard here :slight_smile:

I got ( I think ) everything setup right and the scenes are changing. However after only three clicks the scene 2 changes itself but with another scene 2 :slight_smile: wich is obviously not what I need!

here is a link with a quick project setup, only few lines of code so I’m probably missing something for sure… any help is much appreciated: http://gamez-factory.com/storyboardTest.zip

here are the lua files if someone can figure it out directly:

testScene1.lua:
[lua]----------------------------------------------------------------------------------

– scenetemplate.lua


local storyboard = require( “storyboard” )
local scene = storyboard.newScene()



– NOTE:

– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.



– BEGINNING OF YOUR IMPLEMENTATION

function changeScene(event)
print(’–’)
print(‘TEST SCENE 1: changeScene() called.’)
storyboard.gotoScene(‘testScene2’, ‘slideUp’, 3000)

return true

end

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view


– CREATE display objects and add them to ‘group’ here.
– Example use-case: Restore ‘group’ from previously saved state.


testImg = display.newImage( group, “TestImg1.png”, 0, 0, true )
print(‘TEST SCENE 1: createScene()’)

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.)


storyboard.purgeScene(‘testScene2’)

testImg:addEventListener(“touch”, changeScene)
print(‘TEST SCENE 1: enterScene() called.’)
print(‘TEST SCENE 1: touch event added.’)

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 listeners, unload sounds, etc.)


testImg:removeEventListener(“touch”, changeScene)

end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view


– INSERT code here (e.g. remove listeners, widgets, save state, etc.)


print(‘TEST SCENE 1: purge.’)

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[/lua]

testScene2.lua:
[lua]----------------------------------------------------------------------------------

– scenetemplate.lua


local storyboard = require( “storyboard” )
local scene = storyboard.newScene()



– NOTE:

– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.



– BEGINNING OF YOUR IMPLEMENTATION

function changeScene(event)
print(’–’)
print(‘TEST SCENE 2: changeScene() called.’)
storyboard.gotoScene(‘testScene1’, ‘slideUp’, 3000)

return true

end

– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view


– CREATE display objects and add them to ‘group’ here.
– Example use-case: Restore ‘group’ from previously saved state.


testImg = display.newImage( group, “TestImg2.png”, 0, 0, true )
print(‘TEST SCENE 2: createScene()’)

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.)


storyboard.purgeScene(‘testScene1’)

testImg:addEventListener(“touch”, changeScene)
print(‘TEST SCENE 2: enterScene() called.’)
print(‘TEST SCENE 2: touch event added.’)

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 listeners, unload sounds, etc.)


testImg:removeEventListener(“touch”, changeScene)

end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view


– INSERT code here (e.g. remove listeners, widgets, save state, etc.)


print(‘TEST SCENE 1: purge.’)

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[/lua] [import]uid: 125690 topic_id: 24048 reply_id: 324048[/import]

I think it was my bad :slight_smile:

I got it working after following carefully the example lua files and using again carefully the scenetemplate.lua So if anybody encounters any problems I would advise to first get very familiar with the scenetemplate.lua file and really understand the example provided with Corona SDK.

However, there are two kind of minor bugs:

  1. When begining transition, the bg image (the only element in my scenes) is shifting left few pixels.

  2. The transition seem to first shift 10-30 pixels up before actually beginning the “slideUp” transition.

Is there a fix for any of these? I use “zoomEven” scale mode.

Thank you! [import]uid: 125690 topic_id: 24048 reply_id: 97043[/import]