"Go to previous screen" button

Hi,

I’m making an app that’s basically a straight-ahead sequence of Director screens: 1 to 2, 2 to 3, 3 to 4 and so on.

Each of these “pages” also has a button that leads to the “info” screen, and the “info” screen has a “back” button that should lead to whichever page we came from.

How can I program this “back” button to know which was the last page I was on before I went to “info”? [import]uid: 98287 topic_id: 16635 reply_id: 316635[/import]

The easiest way would be using a global variable, eg;
[lua]lastScene = “0”[/lua]

Then on scene 1, make it [lua]“sceneOne”[/lua] or whatever the name of that file is.

Then do this in your info scene;

[lua]local function goBack()
director:changeScene(lastScene)
end[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 16635 reply_id: 62187[/import]

Director 1.4 and later also has the idea of a PopUp which is great for these things. It basically overlays the existing screen and when you hit the back button, it will close the popup and put you back where you are.

[import]uid: 19626 topic_id: 16635 reply_id: 62214[/import]