Storyboard: How to have the same background throughout multiple scenes

I am creating a game, and in the main menu you can go to “options”, “how to play”, “choose level”, etc. I want the background to be an active background where there are balls constantly falling out of the sky, and I want that background to be the same throughout all of the mentioned scenes. I was thinking that for every ball that I have falling in the background I could add them to a list, without adding them to the display group. Then, once when the user starts the game ( thats where I want to change the background ), all the items in the list can be added to the storyboard group and can be deleted. 

Would this method work? I’ve never not added a display object to a screen without adding it to the storyboard display group, so I don’t know if this would work out. Is there a better way to do this? Thank you.

(if anyone had a hard time what I was trying to explain just ask me and I can go into further detail)

Have a global function that creates a global display group when you go first go to one of the relevant scenes.

Spawn your balls and add them to this group. Sending it to the back will keep the balls behind your composer scenes. Then remove the group when you go to the game scene.

Main.lua:

[lua]

function showBackground ()

  if _G.bgGroup == nil then

    _G.bgGroup = display.newGroup()

    _G.bgGroup:toBack()

    – add background image behind balls here?

    – setup timer to a global function that will spawn balls and add to _G.bgGroup

  end

end

[/lua]

Game.lua (scene:show, phase == “will”)

[lua]

–cancel timer to global spawning function first

display.remove(_G.bgGroup)

_G.bgGroup = nil

[/lua]

In other scenes:

[lua]

showBackground()

[/lua]

Just FYI, you can also place items into Storyboard’s “stage” which resides separate from individual scenes:

http://docs.coronalabs.com/api/library/storyboard/stage.html

Take care,

Brent

Thank you, this solved my problem.

Have a global function that creates a global display group when you go first go to one of the relevant scenes.

Spawn your balls and add them to this group. Sending it to the back will keep the balls behind your composer scenes. Then remove the group when you go to the game scene.

Main.lua:

[lua]

function showBackground ()

  if _G.bgGroup == nil then

    _G.bgGroup = display.newGroup()

    _G.bgGroup:toBack()

    – add background image behind balls here?

    – setup timer to a global function that will spawn balls and add to _G.bgGroup

  end

end

[/lua]

Game.lua (scene:show, phase == “will”)

[lua]

–cancel timer to global spawning function first

display.remove(_G.bgGroup)

_G.bgGroup = nil

[/lua]

In other scenes:

[lua]

showBackground()

[/lua]

Just FYI, you can also place items into Storyboard’s “stage” which resides separate from individual scenes:

http://docs.coronalabs.com/api/library/storyboard/stage.html

Take care,

Brent

Thank you, this solved my problem.