Sorry for the newbie question. Just started with Corona a few days ago with limited programming experience and have already pieced together about half of my basic app.
Question: I have a screen with 2 buttons. Pressing each button should change screens. Is there a way to dynamically pass a variable in the addEventListener so that I can create one function to switch screens.
Not complete code below, just a general idea.
function pressChangeScreen (event)
director:changeScene (variable)
I dont seem to understand why you want the use the same function to change screens?
here’s the way I do it;
function button1:tap()
director:changeScene('whatever','whatever') -- you can put whatever you want here for transitions etc
end
function button2:tap()
director:changeScene('whatever', 'whatever')-- same thing here
end
button1:addEventListener('tap', button1)
button2:addEventListener('tap', button2)
not sure if thats helpful but thats how I do it in my apps [import]uid: 24641 topic_id: 6706 reply_id: 23729[/import]
Thanks. I was hoping there was a way to have only one function to change scenes and use it multiple times passing the scene name as the variable. It looks like I need to create a function for every button. [import]uid: 38758 topic_id: 6706 reply_id: 23977[/import]