Advantages and disadvantages of using director class?

what is the advantages and disadvantages of using director class?

Can I make a game without it?

im pretty sure you can do anything you want with or without director class, but with it is so much easier to change screens

I don't personally believe there are ANY disadvantages to using Director.

I discovered it 2 weeks into starting with Corona and since then I have used it in every single application I've built for myself and for clients. (40+ apps.)

It is a joy to use and I cannot recommend it highly enough :)

Peach

Looks like i cant miss it. Thanks for the info..!!

No worries; if you need a tutorial there's a nice simple one on Techority :) ("How to change scenes/screens", it's called.)

thanks for the info..!!

I'll take a look at 1.3, but the previous version blows away your scene when you change from it. Imagine switching to the menu to turn off the sound, going back to your game and discovering that your 80234 pts are reset to 0.

Although you can do what I do and have one GameScene that loads levels from a config file, it seems the Director Way (tm) is to put each level into its own lua file. I don't get that at all, assuming that game play is basically the same on every level. Seems like a lot of code duplication.

I like the cool transitions, and if it supports pausing and resuming scenes, it may be worth another look. Easy enough to write a simple SceneManager on your own, though. Mine is about 15-20 lines, stores scenes in a table, and on changeScene(), it pause()'s the prev and play()'s the new one. It optionally delete()'s the prev if you tell it so (like a SplashScreenScene that you only want to run once).

Davemikesell, change points (or whatever you call them in your code) to _G.points

It should clear things up :)

I built OmniBlaster without Director and in retrospect, I think it would have made my life easier for my help screens and such, but my game is just a single on-going game so I didn't see where it would help me much.

I'll probably try to use it for my next project.

As for using _G isn't global variables NOT recommended for performance reason.

Rob

I didn't know about _G, but wouldn't you still have to put all of your game state in there to preserve it on a scene change?

Globals don't impact performance (well, they could hog memory if they're big or there are a lot of them), but they're generally frowned upon because everyone has access to them and if you're fiddling with them in a lot of places, it can become hard to maintain.

Well according to: http://developer.anscamobile.com/content/app-programming-guide

Under Lua: Best Practices

"Avoid global variables. Period. In Lua, you will sacrifice performance if you use global variables. When in doubt, precede your variable declarations with local.

This applies even to functions. In Lua functions are variables too. In long loops, it’s better to assign a function to a local variable. In the following example, the code on the left runs 30% slower than the one on the right! "

don't shoot me, just the messenger.

That's interesting - I didn't know that. Thanks for the education. I didn't consider functions.

Well to add to the fun, any one Lua chunk can have a maximum of 200 local variables.

When I went through my game and de-globaled it, I hit the 200 local variable limit.

My game really didn't break down well into using separate .lua files and being and old school procedural programmer, it ended up the way it is.

When I started on version 1.1, I created several Lua tables and put my loose variables in. I grouped things like all my award varaibles and made them like award.score, award.rank, etc. I have a lot of function in my main.lua chunk, something Director would solve.

I'm not sure if using lua tables in this fashion is wise either, but . . .

> As for using _G isn't global variables NOT recommended for performance reason.

Hehe, I didn't really know that when I made bubble ball. I have about 50 _G variables, and 6 of them are tables, big ones. :-) I found out shortly after, but what's done is done.

views:1564 update:2011/10/12 18:33:00
corona forums © 2003-2011