Adding sceneGroup:insert(object) makes the object invisible..

So lets say i have an object and it show up like normal with this code…

function scene:create( event ) local sceneGroup = self.view local box = display.newImageRect( "box.png", 1080, 1920) end

But when i add sceneGroup:insert(box) it makes the box disappear 

function scene:create( event ) local sceneGroup = self.view local box = display.newImageRect( "box.png", 1080, 1920) sceneGroup:insert(box) end

any idea why?

and Btw thats is like the only code i have in that lua file… including all the other things to make it work… like composer and stuff…

thanks!

Lua objects exist in layers.  In Composer, the scene that’s not on screen is in the very back.  The next layer is the scene that’s on screen.  The third layer is any display object that’s not in a scene group and finally the  top most layer is any native.* object.

Each group is it’s own set of layers.  The order you insert things into the group is the reverse order they show in the screen.  That is the first thing you should insert in a group is the background.  The last thing you insert is the top most object.

Following these rules, there are two likely scenarios.  First, you’re not putting your background in your scene’s view group (or you have something in your main.lua that’s sitting on top) and it’s sitting on top of your scenes or secondly you are putting it in your group, but not first and it’s hiding all the other objects you have already inserted.

Rob

Well see im just making an example… this isnt in my code… but like in scene:show if i add the sceneGroup like that then my objects dont appear …

Are there other objects they could be hiding behind?

you were correct they were hiding behind the menu scene… how do i add a scene group to this code?

local MyButton = widget.newButton { left = 110, top = 285, width = 70, height = 50, defaultFile = "PlayBtn.png", onEvent = handleButtonEvent, }

Nvm i got it… thanks for the help tho… next time you dont have to explain things super in detail 99% of the time haha i usually get things in the simplest explanations … thanks!

Lua objects exist in layers.  In Composer, the scene that’s not on screen is in the very back.  The next layer is the scene that’s on screen.  The third layer is any display object that’s not in a scene group and finally the  top most layer is any native.* object.

Each group is it’s own set of layers.  The order you insert things into the group is the reverse order they show in the screen.  That is the first thing you should insert in a group is the background.  The last thing you insert is the top most object.

Following these rules, there are two likely scenarios.  First, you’re not putting your background in your scene’s view group (or you have something in your main.lua that’s sitting on top) and it’s sitting on top of your scenes or secondly you are putting it in your group, but not first and it’s hiding all the other objects you have already inserted.

Rob

Well see im just making an example… this isnt in my code… but like in scene:show if i add the sceneGroup like that then my objects dont appear …

Are there other objects they could be hiding behind?

you were correct they were hiding behind the menu scene… how do i add a scene group to this code?

local MyButton = widget.newButton { left = 110, top = 285, width = 70, height = 50, defaultFile = "PlayBtn.png", onEvent = handleButtonEvent, }

Nvm i got it… thanks for the help tho… next time you dont have to explain things super in detail 99% of the time haha i usually get things in the simplest explanations … thanks!