I am using director for level transitions but the sizes of the level backgrounds are all off. Whatever I try doesn’t seem to change anything. What is the best way to change the background size to fit the screen. Thanks. [import]uid: 94237 topic_id: 17935 reply_id: 317935[/import]
I fixed that problem, but the buttons are behind the background. How do I fix this?
[import]uid: 94237 topic_id: 17935 reply_id: 68462[/import]
Change the order in the file.
A file is executed linearly so whatever you run last in the code will show up on top of others (closer to the user).
In your case, place the part to create background first (top of the code) than the buttons.
[import]uid: 39031 topic_id: 17935 reply_id: 68463[/import]
You can also use myButton:toFront() – it’s a pretty useful function.
Cheers,
Naomi [import]uid: 67217 topic_id: 17935 reply_id: 68465[/import]
thanks! I’ll give those a try
[import]uid: 94237 topic_id: 17935 reply_id: 68466[/import]
thats odd, the button is after the background but still showing up behind it. It doesn’t seem to be responding to the toFront either [import]uid: 94237 topic_id: 17935 reply_id: 68470[/import]
That sounds strange. Do you have your buttons set to visible? (i.e., isVisible = true, and alpha = 1) Also, are you sure they are behind the background? And, if they are behind the background, how do you know if they are even there? Is your background actually transparent, and you are seeing the buttons? Not sure what to think…
Naomi
[import]uid: 67217 topic_id: 17935 reply_id: 68474[/import]
the buttons do work and when I was experimenting with the background I saw the button when the background was offcenter. I’m not sure if they are sent to visible, is that needed? [import]uid: 94237 topic_id: 17935 reply_id: 68480[/import]
Hey, shakmbakm, if you never set the button’s isVisible property to false, I don’t think you need to set it. Same goes true with the alpha property. At this point, I have no idea what might be your problem. Maybe you need to post some code, and cross your fingers for someone to come by and help you out.
Naomi [import]uid: 67217 topic_id: 17935 reply_id: 68487[/import]
Have you added the background and buttons to display groups? If so, and they are in different display groups, the order of those groups matter too. Make sure that whatever display group the buttons are in is inserted after the display group the background is in.
Does that make sense to you? [import]uid: 74503 topic_id: 17935 reply_id: 68492[/import]
Yeah the buttons are currently after the background. I’ll show some code here. [code] function new()
local localGroup = display.newGroup()
local background = display.newImage(‘titleNoButtons.png’, true)
background:scale(display.contentWidth/640, display.contentHeight/960)
background:setReferencePoint(display.TopLeftReferencePoint)
background:toBack()
local startButton = display.newImage(‘newGame.png’,true)
startButton:toFront()
startButton.x = 230
startButton.y = 300
startButton:setReferencePoint(display.CenterReferencePoint)
startButton.scene = “world1Mini” [import]uid: 94237 topic_id: 17935 reply_id: 68493[/import]
The only thing I can see wrong there is that you’re not adding either of the objects to the ‘localGroup’ display group.
Try
[lua] function new()
– Creates a new display group
local localGroup = display.newGroup()
local background = display.newImage(‘titleNoButtons.png’, true)
background:scale(display.contentWidth/640, display.contentHeight/960)
background:setReferencePoint(display.TopLeftReferencePoint)
– Inserts the background into the display group 1st (bottom of the display stack)
localGroup:insert(background)
local startButton = display.newImage(‘newGame.png’,true)
startButton:toFront()
startButton.x = 230
startButton.y = 300
startButton:setReferencePoint(display.CenterReferencePoint)
startButton.scene = “world1Mini”
– Inserts the startButton into the display group 2nd (on top of the display stack)
localGroup:insert(startButton)[/lua]
I’ve removed the calls to toBack() and toFront() as they should be redundant here. Give this a go and see if it sorts it out for you. If not, maybe post some more code.
[import]uid: 74503 topic_id: 17935 reply_id: 68497[/import]
Hey, shakmbakm, when do you insert background and startButton into localGroup? The code you supplied does not show how/when you insert them. The order in which you insert these elements will make a world of difference. Also, you need to use the toBack() and toFront() after you insert them to the localGroup to make any difference.
Naomi [import]uid: 67217 topic_id: 17935 reply_id: 68499[/import]
yeah that was it, I forgot to insert the background. Thanks everyone! [import]uid: 94237 topic_id: 17935 reply_id: 68500[/import]
No problem. Glad you got it sorted. [import]uid: 74503 topic_id: 17935 reply_id: 68501[/import]
One other thing, in your example code you do background:toBack() immediately after loading the background. You want to put that AFTER you have loaded all your buttons.
Peach
[import]uid: 52491 topic_id: 17935 reply_id: 68539[/import]