Tutorial: Easy Screen (aka "scene") Management

When first starting out, screen management (I called it “scene management” then), was by far the hardest concept to get my head wrapped around (as well as project organization–I wasn’t used to dealing with potentially HUGE text files).

After developing 3 games (one is currently waiting for review), I’ve been able to refine a system used in all of our games that has proven to be very effective, and pretty easy to implement.

I created a tutorial and zipped up a project template that should help you if you’re currently struggling/confused with this process.

Get the project files and the “cheat sheet” here:

–> http://ideveloper.kodingen.com/2010/easy-screen-management-in-corona/

Feel free to ask any questions you have. It might be confusing at first, but study it for a little bit and you’ll see how simple it really is. [import]uid: 7849 topic_id: 2501 reply_id: 302501[/import]

Today I modified the template files to perform better, you can download the updated corona project template here:

–> http://cl.ly/2k3e

The only thing I changed was that the main.lua’s enterFrame listener is removed when another scene is loaded (to free up some processing resources), and then restored right before unloading the scene/screen. [import]uid: 7849 topic_id: 2501 reply_id: 7294[/import]

Hiya,

I’m pretty new to lua, and I would like to get this template working, one slight issue is that upon calling gameover( “screen3”) from screen1.lau the global variable nextScreen seems to stay empty within main.lua, but its value is “screen3” within screen1.lua

hope you can help. :slight_smile:

[import]uid: 10757 topic_id: 2501 reply_id: 9949[/import]

@fishmilkshake: Take a look at Ricardo’s Director Class, it’s a much better (and easier) method of scene management:

http://developer.anscamobile.com/code/director-class-10

Be sure to read the comments, there’s some good information you need to follow (towards end of comments thread) regarding event listeners though.

Hope that helps!
[import]uid: 7849 topic_id: 2501 reply_id: 9981[/import]