In composer, any display objects that you **DO NOT** put into the scene’s view group sits on top of other composer scenes. This is called “HUD” mode and the purpose was you could have your UI elements (health, inventory, etc.) sit on top of your actual composer scenes.
You can create those elements in main.lua and put them in a display.newGroup() so you can transition them on and off screen when you need them and not have them connected to the composer scenes.
–Create a “health meter” image which should appear above all scenes
local meter = display.newImage( “images/progress_bar_12.png” )
meter.anchorX = 0
meter.anchorY = 1
meter.x, meter.y = 20, display.contentHeight-20
HUD:insert(meter)
and then later
composer.gotoScene(“main_game_loop”, options)
then within main_game_loop.lua I do this
composer.gotoScene(“main_menu”, options)
and finally in main_menu.lua I do this
composer.gotoScene(“main_game_loop”, options)
and the result is that the health bar stays in front of the scene transitions at all time.
roaming… I didn’t try your suggestion yet, but I suspect that would also work. I was just lazy and Rob’s seemed easier to try
thanks a lot guys! I started writing game code before the internet was around and so I often forget that asking people who know more can save hundreds of hours which I think you guys just did!
In composer, any display objects that you **DO NOT** put into the scene’s view group sits on top of other composer scenes. This is called “HUD” mode and the purpose was you could have your UI elements (health, inventory, etc.) sit on top of your actual composer scenes.
You can create those elements in main.lua and put them in a display.newGroup() so you can transition them on and off screen when you need them and not have them connected to the composer scenes.
–Create a “health meter” image which should appear above all scenes
local meter = display.newImage( “images/progress_bar_12.png” )
meter.anchorX = 0
meter.anchorY = 1
meter.x, meter.y = 20, display.contentHeight-20
HUD:insert(meter)
and then later
composer.gotoScene(“main_game_loop”, options)
then within main_game_loop.lua I do this
composer.gotoScene(“main_menu”, options)
and finally in main_menu.lua I do this
composer.gotoScene(“main_game_loop”, options)
and the result is that the health bar stays in front of the scene transitions at all time.
roaming… I didn’t try your suggestion yet, but I suspect that would also work. I was just lazy and Rob’s seemed easier to try
thanks a lot guys! I started writing game code before the internet was around and so I often forget that asking people who know more can save hundreds of hours which I think you guys just did!