Search code examples
luacoronasdkreloadplaybackscene

Reloading a game with corona sdk


I am creating my first iPhone game and cannot figure out how to reload my game.

I am using coronaSDK and have tried to use their composer API. When the player dies a button with "play again" appears and when he touches it I direct him to a scene called "reload.lua" with composer.gotoScene("reload").

In this scene I have the following code:

function scene:show(event)
    local sceneGroup = self.view
    local phase = event.phase

    if (phase == "will") then

    elseif (phase == "did") then
        local replay = display.newImage('star1.png', 100, 300)
        composer.removeScene("level1")
        composer.gotoScene("level1")
    end
end

However, this only adds level1 on top of the existing one and does not remove the one that has been used. Any ideas on how I could successfully remove level1 or reload my game?


Solution

  • While this is based on Composer's older brother Storyboard, the concepts still apply to Composer. It explains the various issues with trying to reload scenes, recommendations on how to manage it:

    http://coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/