Scene navigation without using storyboard/composer/director

Hi there,

I am wondering is it possible to have scene navigation without using storyboard/composer/director?

I have been reading up on an MVC approach but it seems quite complex for whats needed.

Currently I have a set of projects all setup individually with their own main.lua which has the code and assets etc but I want to combine them into one bigger project and have a menu to go between them.

Is there a more basic way of doing this without intergrating storyboard into the app or a good MVC example?

You can of course manually manage it yourself manually. All storyboard/composer/director do is to make it easier. If you manually cancel timers/transitions, remove display objects etc. I see no reason why not. But why are you not using composer? You can just edit a few lines of code and make each main.lua a new scene.

Hi,

thanks for the reply. Its part of an assignment and a requirement is to avoid using composer etc. Manually removing display groups etc is fine but what about scene management and calling in another file. For example having main.lua and then changing the others to be page1.lua, page2.lua etc and having a menu to go between them and load that page into the view.

Oh I see. You can do something like;

local page1 = require( "page1" )

You need to have the page1.lua in the same directory as your main.lua. You can just create a function like destroyScene() on each lua where you remove everything you created. And when you want to change the scene just use require. That should work.
 

I wrote a Composer-a-like which has Scenes as first class objects. It’s pretty much the same functionality, open source MIT http://coronadev.blogspot.co.uk/2014/05/composer-with-objects.html it should be possible to write something that wraps a main file as a Scene and then add multiple instances - my font demo program does something similar.

I’m guessing your main.luas don’t use Storyboard/Composer ?

Hi - thanks for the replies. No the main.lua is actually pretty basic and just has an image with an event handler that then calls a menu screen. This has 6 images with event handlers on them that then require a lua file depending on which one you choose. I am having another issue though someone might be able to help with.

At the minute I have each ‘game’ in its own lua file which I require from the menu file. I also have a HUD file which contains a copy of this menu in an external module. I have a button at the top of each game and when you press it the HUD is required, drawn off screen and then transitions down giving the effect it slides on to the screen. At this point in the background I am removing the display objects from the current game, stopping transitions etc. Then when you click on the game you want from the HUD that file is required and you can play it. My problem is that when I am removing the objects they seem to be completely gone. When I go back to one of the levels I have previously been on i am getting a black screen like the display group is empty. The content of the lua file is not being reloaded or redrawn. Now if I was able to use storyboard etc I would be doing destroy scene etc but I cant use that option. Any suggestions on what is going wrong or how I can recall the objects and draw them again when I require the file a second time around?

To actually reload the module, we need to remove it from the cache first:

> package.loaded.mymodule = nil
> mymodule = require “mymodule”

You can of course manually manage it yourself manually. All storyboard/composer/director do is to make it easier. If you manually cancel timers/transitions, remove display objects etc. I see no reason why not. But why are you not using composer? You can just edit a few lines of code and make each main.lua a new scene.

Hi,

thanks for the reply. Its part of an assignment and a requirement is to avoid using composer etc. Manually removing display groups etc is fine but what about scene management and calling in another file. For example having main.lua and then changing the others to be page1.lua, page2.lua etc and having a menu to go between them and load that page into the view.

Oh I see. You can do something like;

local page1 = require( "page1" )

You need to have the page1.lua in the same directory as your main.lua. You can just create a function like destroyScene() on each lua where you remove everything you created. And when you want to change the scene just use require. That should work.
 

I wrote a Composer-a-like which has Scenes as first class objects. It’s pretty much the same functionality, open source MIT http://coronadev.blogspot.co.uk/2014/05/composer-with-objects.html it should be possible to write something that wraps a main file as a Scene and then add multiple instances - my font demo program does something similar.

I’m guessing your main.luas don’t use Storyboard/Composer ?

Hi - thanks for the replies. No the main.lua is actually pretty basic and just has an image with an event handler that then calls a menu screen. This has 6 images with event handlers on them that then require a lua file depending on which one you choose. I am having another issue though someone might be able to help with.

At the minute I have each ‘game’ in its own lua file which I require from the menu file. I also have a HUD file which contains a copy of this menu in an external module. I have a button at the top of each game and when you press it the HUD is required, drawn off screen and then transitions down giving the effect it slides on to the screen. At this point in the background I am removing the display objects from the current game, stopping transitions etc. Then when you click on the game you want from the HUD that file is required and you can play it. My problem is that when I am removing the objects they seem to be completely gone. When I go back to one of the levels I have previously been on i am getting a black screen like the display group is empty. The content of the lua file is not being reloaded or redrawn. Now if I was able to use storyboard etc I would be doing destroy scene etc but I cant use that option. Any suggestions on what is going wrong or how I can recall the objects and draw them again when I require the file a second time around?

To actually reload the module, we need to remove it from the cache first:

> package.loaded.mymodule = nil
> mymodule = require “mymodule”