Restarting Scene using composer.

hi there, I have 20 levels in my game, do i need to create 20 dummies to restart it? is there anyone knows how to easily restart a game without using so many lua files? Thanks! Godbless!

Welcome to the forums.

No you can get away with one or two cut scenes depending on how your game is structured.  In multi-level games, I have a scene for successfully beating the level which takes me to the next scene.  Then I have a failed cut scene that takes me back to replay that level, or if out of lives, go to the game over scene.

There are multiple strategies for using a single “nextscene” type cut scene.  You could use composer parameters to pass the current level from scene to scene.  You could use composer’s setVariable/getVariable functionality to pass your current level through the system and in the cut scene, add one to the current level and then go to scene based on that value.  You could choose to keep track of that data in a table that is available to all scenes.  Many different ways to attack that specific issue.

You should also consider your 20 different levels.  Are they all played using the same logic?  If so you can get a way with one level/game scene and have it use data to change each level’s different behavior.  If each level is drastically different so much that it needs unique code for each level, then you probably want different .lua files for each scene.

Rob

Welcome to the forums.

No you can get away with one or two cut scenes depending on how your game is structured.  In multi-level games, I have a scene for successfully beating the level which takes me to the next scene.  Then I have a failed cut scene that takes me back to replay that level, or if out of lives, go to the game over scene.

There are multiple strategies for using a single “nextscene” type cut scene.  You could use composer parameters to pass the current level from scene to scene.  You could use composer’s setVariable/getVariable functionality to pass your current level through the system and in the cut scene, add one to the current level and then go to scene based on that value.  You could choose to keep track of that data in a table that is available to all scenes.  Many different ways to attack that specific issue.

You should also consider your 20 different levels.  Are they all played using the same logic?  If so you can get a way with one level/game scene and have it use data to change each level’s different behavior.  If each level is drastically different so much that it needs unique code for each level, then you probably want different .lua files for each scene.

Rob