Director 1.3 released!

Right on time, thank you!

Changes are huge but all makes sense, I wasn't expecting that kind rewrite :)

I'll try that with my current project and report back soon...

The new version is fantastic. Great work and thanks, Ricardo!

@Ricardo, got a Q if you can help me plz...

Regarding "Call to clean() function removed"

I was using cleanup function to remove unnecessary sound files, sprite sheets as well as the particles (Particle Candy) used on screen AFTER the scene is changed.

I can use my own clean function as suggested but I'll still need that function called AFTER the scene change.

For example, I have some sprite & particle animation (Particle Candy) on screen. If I assign my clean function to the button that changes the screen, everything disappears on screen before the scene change happen.

So, do you have any suggestion for that? For now I think I'll either use a loader screen that cleans up the previous one then calls the next screen OR I'll put back clean up function to 1.3.

If you really need you can put it back. No worries but my advice is to put it as a method, like this:

1
localGroup.clean = function () ... end

Hi Ricardo... 1.3 looks very nice indeed!

I'm also very keen on the clean function, but would like director to call the function automatically each time i change the scene. If I place "localGroup.clean = function () ... end" in my scene modules
what changes would i need to do in the director module in order to call the clean function on each scene change?

Thanks

Hi!

First time really using Director.

How do I get it to use @2x images for higher resolution screens?

Cheers!

Amazing work! Director is what actually convinced me to make Bubble Ball in Corona (Scene management before director was horrible, and I didn't understand it at all), so thank you!

The clean function is very important to the Director Class, I feel, and I'd really like to get a version of 1.3 with this functionality reinstated.

If people didn't know what it was, they don't know how to manage the memory of their apps and shouldn't be determining the direction of your Director Class.

This also means that I need to go over and change all the projects that use the Director Class before they will work as I intended them to. Seems strange to just remove an important hook that projects are relying on to be successful.

Apart from this issue, you're doing some great work here... thanks

@hudson.graham

+1

i second that hudson.graham , not only we have to change the existing projects we also have to call that function every time ourselves which can cause lot of errors ... so far i tried 1.3 and with out clean function i am having funny errors...

so please restore the clean function

+1 restore the clean function

Ok guys, let's make a deal with clean function. It can be as a module function or an object function, this is one of the things that made me cut it off.

On director 1.3 I'm suggesting to use every scene as an object of a module, so the clean function must be inside the object, ok? It could be something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
new = function ( params )
  local localGroup = display.newGroup()
 
  ...
 
  localGroup.clean = function()
     -- clean code
  end
 
  ...
 
  return localGroup
end

There is a third option, sending the function as a parameter, like this:

1
2
3
4
5
clearSprites = function ()
  ...
end
 
director:changeScene( { clean=clearSprites }, "scene", "moveFromRight" )

Thanks ricardorauber for getting onto this so quickly.

My background is from AS3/Drupal and I have been finding my feet over the last few weeks with lua/corona and feel I've finally found how to structure my code in OOP Classes.

So, to get the best outcome here, I'm going to show my class structure and how it is working with the Director Class 1.2. Hopefully this will get others to throw in their examples and we can get the best outcome for all.

DirectorSceneExample.lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--
-- Project: DirectorClean
-- Version: 1.0.1
-- Date: 4 Jul 2011
-- Description: An example of the current use of the Director Class using the clean function
--
-- Version: 1.0
-- Managed with http://CoronaProjectManager.com
--
-- Copyright 2011 Hudson Graham. All Rights Reserved.
-- 
 
module(..., package.seeall)
 
---------------------------------------------------------------
-- Import class
---------------------------------------------------------------
 
require "DirectorClassExample"
 
--local logger = require("Logger")
 
---------------------------------------------------------------
-- LOCAL VARIABLES
---------------------------------------------------------------
 
---------------------------------------------------------------
-- GROUPS
---------------------------------------------------------------
 
local localGroup = display.newGroup()
 
---------------------------------------------------------------
-- DISPLAY OBJECTS
---------------------------------------------------------------
 
local classRef
 
---------------------------------------------------------------
-- INIT VARS
---------------------------------------------------------------
 
local function initVars ()
        
        classRef = DirectorClassExample:getInstance()
        
        -----------------------------------
        -- Inserts
        -----------------------------------
        
        localGroup:insert(classRef)
        
        -----------------------------------
        -- Positions
        -----------------------------------
        
        -----------------------------------
        -- Colors
        -----------------------------------
        
        -----------------------------------
        -- Listeners
        -----------------------------------
        
        -----------------------------------
        -- Listeners
        -----------------------------------
        
end
 
---------------------------------------------------------------
-- CLEAN
---------------------------------------------------------------
 
function clean ( event )
        -- Custom logger for checking that all the memory before cleaning
        --logger.traceMemory("start", "ScreenGame")
        
        localGroup:remove(classRef)
        
        classRef:destroy()
        classRef = nil
        
        localGroup:remove()
        localGroup = nil
        
        -- Custom logger for checking that all the memory has been cleared after doing the clean
        -- logger.traceMemory("end", "ScreenGame")
end
 
---------------------------------------------------------------
-- NEW
---------------------------------------------------------------
 
function new()
        
        -----------------------------------
        -- Initiate variables
        -----------------------------------
        
        initVars()
        
        -----------------------------------
        -- MUST return a display.newGroup()
        -----------------------------------
        
        return localGroup
        
end

Ricardo,

My vote goes for module function working as before, which will also provide full backwards compatibility.

But of course integrating both (module & group at the same time) wouldn't hurt. Your suggested "." type will be just fine for the object function...

3rd option isn't my choice as it won't be backwards compatible unless we edit all director calls.

Congratulations for the new version and also the support!

I have the same thoughts as PixelEnvision.
The best is the integration (module and group).

Group is most important to me.
Thank you for looking into this.

By the end of the month I think I will release version 1.4 with clean function, better debug and some other things.

I love Director 1.3
Using it in my new non-game app. Works well :)

Hmm, I have some code that worked fine with previous versions, but now with director 1.3 I randomly get error popups when that code is run, about 1 out of 10 times. Any ideas why? Other than that, it works great and fixes a lot of bugs!

Thanks Ricardo!

Great stuff Ricardo. Works like a charme.

I started with 1.3 and do not have any issues with this setup.

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