Hi y’all,
I would like to know how to get Director recognize an outside file to be used as a background.
I have the following for my background.lua code (note, there’s a lot more than just the background, but I’m testing just with one image and it still acts weird):
-- background
local function backgroundImg()
local bg = display.newImage( "bg.png" )
bg.width = 480
bg.height = 320
bg.x = 240
bg.y = 160
end
backgroundImg()
On my menu.lua file, I have the following:
function new()
local localGroup = display.newGroup()
-- load background
local bgImg = require( "background" )
return localGroup
end
At this point, my background loads fine…
however, when I add additional images to my menu.lua file:
function new()
local localGroup = display.newGroup()
-- load background
local bgImg = require( "background" )
-- play button
local play\_btn = display.newImage("playbtn.png", 203, 165)
localGroup:insert(play\_btn)
return localGroup
end
If I go run the above, I get the ‘play button’ image, but now I lost my background.
If I go back to my background.lua file and add the following:
function new()
local localGroup = display.newGroup()
-- background
local function backgroundImg()
local bg = display.newImage( "bg.png" )
bg.width = 480
bg.height = 320
bg.x = 240
bg.y = 160
localGroup:insert(bg)
end
backgroundImg()
return localGroup
end
If I run again from my menu.lua file…now the background shows, but NOT the ‘play button’
What am I doing wrong?
Any help will be greatly appreciated.
Thanks,
RD [import]uid: 7856 topic_id: 6701 reply_id: 306701[/import]