Zac Baker
Zac Baker

Reputation: 37

How to go to previous scene in corona sdk?

basicly if the user has never played the game before i want it to take them to scene1, if they haven't i want it to take them to the previous scene they were on, how do i do this.

I've been trying a while and heres the code i came up with and I;m sure it is nothing like it should be but the problem is i can't find an answer, any help? thanks!

 local function onSceneTouch( event )
    if event.phase == "ended" then
       scene = storyboard.getPrevious()
       if scene == "main" then
         storyboard.gotoScene( "scene1", "slideLeft", 500 ) else
         storyboard.gotoScene( --what goes here? previous scene?, "slideLeft", 500)
         return true
       end
    end
 end

Upvotes: 2

Views: 1450

Answers (1)

IqraDar
IqraDar

Reputation: 53

try this

local previousScene=storyboard.getPrevious()
storyboard.gotoScene(previousScene)

Upvotes: 3

Related Questions