Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
I don't understand how to restart my game — Gideros Forum

I don't understand how to restart my game

simransimran Member
edited May 2014 in General questions
The code in my game is such that I have created classes and created class:init() function and that's how most of my codess start, though I am clueless that How do I really restart my game?

I am posting some of the important parts of the game which I might need while I restart the game:

dummy = Core.class(Sprite)

function dummy:init()

--all code

end
function WatchHands:init()
--all code
end

How to call these at the location where I want to restart the game?

Comments

  • ar2rsawseenar2rsawseen Maintainer
    I usually do that using SceneManager (https://github.com/gideros/Scene-Manager)

    So basically you define the scenes you have in main.lua :
    --define scenes 
    sceneManager = SceneManager.new({ 
        --start scene ["start"] = Start, 
        --pack select scene ["pack_select"] = PackSelect, 
        --level select scene ["level_select"] = LevelSelect, 
        --level itself ["level"] = Level 
    })
    --add manager to stage 
    stage:addChild(sceneManager)
    --and go to the first scene you have
    sceneManager:changeScene("start", 1, SceneManager.flipWithFade, easing.outBack)
    So then you create a separate file for each scene, for example:
    Level = Core.class(Sprite)
     
    function Level:init()
        -- here you create everything you want for your scene as
        --dummy or WatchHands instances, but not definitions
        --only instances, definitions should be in separate files
    end
     
    --and then when you want to restart a level, you just restart a scene:
    function Level:restart()
        sceneManager:changeScene("level", 1, SceneManager.flipWithFade, easing.outBack)
    end
    Check a game template for more examples:
    https://github.com/ar2rsawseen/GameTemplate

    More about it here:
    http://appcodingeasy.com/Gideros-Mobile/Gideros-Mobile-Game-Template
Sign In or Register to comment.