Director Class 1.2 + More Efficient cleanGroups Function

Hi everyone,

I’m a big fan of the Director class, as I use it in many of my own projects.

Last night I was answering a question in the forums about removing an entire display group (as well as it’s children), so I pasted the cleanGroups() function from the Director class and told them to use that.

Well, user FrankS kindly pointed out to me that the cleanGroups function (the one used in Director class) is not entirely efficient because there are some instances where display objects (not groups, but actual display objects) get left behind.

He explains it all in this post:
http://developer.anscamobile.com/forum/2011/03/06/remove-all-objects#comment-26557

And I’ve got a modified version of Director Class 1.2 you can replace your projects with that uses the modified cleanGroups function here:

http://cl.ly/52MI

Here’s exactly what was changed:

  • Added function: isDisplayObject() which is used by cleanGroups()

  • Modified cleanGroups to be more efficient.

  • Anywhere else in the module that calls cleanGroups(), I added a line directly below it to re-create the group that was cleaned (the cleanGroups will completely destroy whatever group it cleaned out).

@Ricardo Rauber: Please consider making these changes official in the next version release! (1.3?)

And special thanks to FrankS for actually providing the new cleanGroups() function (as well as the isDisplayObject() function).

[import]uid: 7849 topic_id: 7515 reply_id: 307515[/import]

I’m afraid I found that using this breaks my “moveFrom”/“overFrom” transitions.

The problems can be replicated by putting the new director.lua in Ricardo’s demo program. [import]uid: 35852 topic_id: 7515 reply_id: 27317[/import]

The reason why it breaks, I assume, is because Ricardo’s director class calls cleanGroups() before a transition takes place. The new cleanGroups() function is so efficient, it removes all display objects and groups within that group AND the group itself.

You might try moving the call to cleanGroups() to the onComplete function of the transition, so that cleanGroups isn’t called until after the transition is over (instead of before the transition takes place).

If I get some time I’ll work on modifying it (1.2b perhaps?) to ensure all the older transitions work. In the meantime, it works great without the special transition effects (if you just want to go from screen a to screen b). [import]uid: 7849 topic_id: 7515 reply_id: 27319[/import]

Hey there. First of all I think director is fantastic, thanks! I’m having 2 problems that I wonder if you know anything about:

  1. I have a button that sometimes triggers an alert. When the alert is triggered, and I hit “OK” to cancel the alert, suddenly all of the buttons stop working, preventing me from using director to transition to the next page. Does the native.alert cause problems in general, or is there a workaround?

  2. I noticed that native.newTextField doen’t animate along with everything else, even when placed in its own display group (which is then placed into the main localGroup for director). My workaround is to remove them from the director group before animating, but I am wondering if you know of a way to animate the native.newTextField objects?

Thanks a bunch!
-Steven [import]uid: 40611 topic_id: 7515 reply_id: 27823[/import]