Director question

Hi, i wanted to ask you a question.
I’m using the director library to make the scenes of my game, but there is a problem. I want to make an option button in menu.lua, so I have to make option.lua. How can i make a bottom in option.lua with changes the background of menu.lua??? [import]uid: 27760 topic_id: 25769 reply_id: 325769[/import]

Hey there, sorry, I only just saw your FB message.

You’d need to set a variable in options.lua that menu would then see, or save it to a file and read it back in menu.

Eg in options;
background = 1

then in menu;
if options.background == 1 then
–show image 1

otherwise if it equaled 2 show 2, etc.

There are a number of ways of fine tuning this but that should be enough to get you started :slight_smile: [import]uid: 52491 topic_id: 25769 reply_id: 104900[/import]

Thanks. So I have to write in options:

background=1  

And in menu.lua something like this:

local btn=display.newImage("btn.png")  
  
local function changeBkg(event)  
if options.background ==1 then  
display.newImage("background2.png")  
end  
end  
end  
  
btn:addEventListener("touch", changeBkg)  
  

P.S. Do I have to write something before background=1 in options.lua?

[import]uid: 27760 topic_id: 25769 reply_id: 104919[/import]

That should work fine, you may need to do require “options” at the start of your menu.lua file as well.

Let me know how that works for you and if you have any issues.

Peach :slight_smile: [import]uid: 52491 topic_id: 25769 reply_id: 105021[/import]