Background image covers everything when inserting everything into localGroup

I’m trying to use a background image with a practice project I’m working on. But when I use localGroup:insert to activate the three system text lines that I’m using as buttons that have event listeners, the background image is the only thing that is seen. If I “comment out” the three localGroup:insert, then the three text buttons reappear, but of course they can’t work. So what am I doing wrong? Here is my code. If you remove the – of lines 53, 54, and 55, the background will cover everything. If you comment out line 6, the text buttons will appear.

Thanks!

[lua]module(…, package.seeall)

display.setStatusBar( display.HiddenStatusBar )
local background = display.newImage( “kwkbackground.png”, 0, 0, true )
–background.x = display.contentWidth / 2
–background.y = display.contentHeight / 2

function new()

– we store everything inside this group at the end
local localGroup = display.newGroup()

– change scene function
function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene, “moveFromRight”);
end
end

– load cms site
local function visitSite(e)
system.openURL( “http://psimediapublishers.com/products.htm” )
end

– menu buttons

local hopeThisWorks = display.newText( “New Play Button”, 0, 0, native.systemFontBold, 64)
hopeThisWorks:setReferencePoint(display.CenterReferencePoint);
hopeThisWorks.x = _w/2;
hopeThisWorks.y = _h/2-100;
hopeThisWorks.scene = “selectlevel”;
hopeThisWorks:addEventListener(“touch”, changeScene);

local btn_exit = display.newText(“Exit”, 0, 0, native.systemFontBold, 64);
btn_exit:setReferencePoint(display.CenterReferencePoint);
btn_exit.x = _w/2;
btn_exit.y = _h/2;
btn_exit.scene = “exit”;
btn_exit:addEventListener(“touch”, changeScene);

local btn_apps = display.newText(“See Our Other Apps!”, 0, 0, native.systemFontBold, 64);
btn_apps:setReferencePoint(display.CenterReferencePoint);
btn_apps.x = _w/2;
btn_apps.y = _h/2+100;
btn_apps.scene = “apps”;
btn_apps:addEventListener(“touch”, visitSite);

— insert everything into the localGroup
–localGroup:insert(hopeThisWorks)
–localGroup:insert(btn_exit)
–localGroup:insert(btn_apps)

– clean everything up
clean = function ()

end

– do not remove lest the sky shalt fall upon thine head
return localGroup

end
[lua] [import]uid: 39859 topic_id: 34263 reply_id: 334263[/import]

I just tested your code and everything seems to work as it should. I did use my own background image though, because you didn’t provide yours, but that shouldn’t matter.

Have you tried inserting the background image into the group before the text objects? For example:

localGroup:insert(background) localGroup:insert(hopeThisWorks) localGroup:insert(btn\_exit) localGroup:insert(btn\_apps) [import]uid: 12217 topic_id: 34263 reply_id: 136257[/import]

It is just the z order so if you want your background to persist outside of the group then you can do as you have done, but finally you could just call background:toBack(). Or as suggested, you can add your background to the group as the first item. [import]uid: 106799 topic_id: 34263 reply_id: 136259[/import]

Thanks guys! I’ll try both approaches. I think I might even try background:toBack() for a different problem I’m having that does not insertGroup.

Thanks again and Merry Christmas to you both.

Psi [import]uid: 39859 topic_id: 34263 reply_id: 136280[/import]

Display groups work like layers. The first thing you insert is the bottom most thing. Add another object and it stacks on top (like laying sheets of paper on each other). If your background is the last thing inserted into the group it’s going to be on top of everything hiding anything under it.

Either insert it as the first thing in the group or do something like this:

background:toback()

after you’ve inserted it into the group.
[import]uid: 199310 topic_id: 34263 reply_id: 136282[/import]

I just tested your code and everything seems to work as it should. I did use my own background image though, because you didn’t provide yours, but that shouldn’t matter.

Have you tried inserting the background image into the group before the text objects? For example:

localGroup:insert(background) localGroup:insert(hopeThisWorks) localGroup:insert(btn\_exit) localGroup:insert(btn\_apps) [import]uid: 12217 topic_id: 34263 reply_id: 136257[/import]

It is just the z order so if you want your background to persist outside of the group then you can do as you have done, but finally you could just call background:toBack(). Or as suggested, you can add your background to the group as the first item. [import]uid: 106799 topic_id: 34263 reply_id: 136259[/import]

Thanks guys! I’ll try both approaches. I think I might even try background:toBack() for a different problem I’m having that does not insertGroup.

Thanks again and Merry Christmas to you both.

Psi [import]uid: 39859 topic_id: 34263 reply_id: 136280[/import]

Display groups work like layers. The first thing you insert is the bottom most thing. Add another object and it stacks on top (like laying sheets of paper on each other). If your background is the last thing inserted into the group it’s going to be on top of everything hiding anything under it.

Either insert it as the first thing in the group or do something like this:

background:toback()

after you’ve inserted it into the group.
[import]uid: 199310 topic_id: 34263 reply_id: 136282[/import]