UPDATE: Please see the recently published Common Storyboard API Questions blog post to see if any questions you have are answered there first.
Jump to content
function scene:myFunction() -- i want to call this function from another lua file end
local myScene = storyboard.getScene("my_scene")
local storyboard = require "storyboard"
storyboard.gotoScene( "scene1" )
-- create image
local background = display.newImage( "bg.png" )
-- do a timer delay or it won't work
display.getCurrentStage():insert( 1, background )
end, 1 )
Before the update gets checked-in (should be very soon), you'll have to do that whenever you do a scene change, so you may want to store a reference to your background object in the storyboard table. I recommend waiting until the daily build with the fix comes out before setting a background image though, so you don't have to go back and modify your code.
Quick Update on What's Coming
The following new things should be available soon, within the next few Daily Builds.
Currently, all of the available effects will leave the current scene in place. However, due to popular demand, I've added some 'sliding' effects that will push the original scene over:
storyboard.purgeAll() - purges all loaded scenes (except for the current scene).
storyboard.removeAll() - removes all loaded scenes (except for the current scene).
storyboard.getPrevious() - returns the previous scene name (as a string).
storyboard.getScene( sceneName ) - returns the specified sceneName's scene object.
In the upcoming update, you will be able to optionally specify a 'sceneName' when calling storyboard.newScene(), so scenes do not actually HAVE to be attached to external modules. For examples, you can create three (or more) different scene objects in one module, and just assign the appropriate listeners to them as you would other objects! (for scene events, of course).
This is a special-use feature, as most will probably be sticking to the scene-per-module method, where no sceneName is specified in your call to storyboard.newScene() — as you are doing now.
I'll update this thread (and the documentation pages) once a Daily Build with these changes is available for download.
Thanks for the feedback/questions everyone!uid: 52430 topic_id: 17828 reply_id: 68244
Community Forum Software by IP.Board