Whats better Director Class or StoryBoard

I'm wondering what is recommended to use for Creating games StoryBoard or Director Class? I need someone(s) opinion to help me pick which one is better?

It depends..I think Director class is tried and tested..You cannot go wrong with it..

Storyboard will take time to get used to. You will have to think through the life cycle of your screen while coding(which is a good thing). There are still some minor issues with Storyboard, like the lag in changing scenes etc..

But long term direction seems to be Storyboard...

thx,
Bejoy

@bejoy thanks for giving advice also another thing when I change scene how would I not have a object thats in group not appear in the next scene?

Sorry for sudden question

sebittas - Not sure if i understand your questions..Generally when you are navigating from first scene to 2nd scene using storyboard, you are moving into a new group object. If you want keep a object constant across scene then make it a global object.

Hope this helps.

i just used to Director class, it very simple and very awesome
for now i prefer to stick with it

Good luck..

@darkconsoles thxs for advice :)

@bejoy sorry for confusion what I meant is using director class when a object is a group. I want to know how to remove a group(s) when I switch scene because every time i switch scene my object group is always in the next scene.

sebittas,
If you are using director class then you can create a lua file each for a scene. Each scene would have the required fields for each scene in the main group. Using director u can then loadScene.

Check out this video, which shows how to transition between scenes..

http://www.youtube.com/watch?v=KudLE8h4kWw

@bejoy seems to have summarized it pretty well.

Director has been around and many people have experience with it and it has a few features that Storyboard doesn't have, like popups and passing parameters.

But Director is supported by its creator and the Community. Ansca can't really help you with it. Storyboard gets you full Ansca support and I do really like their event driven system and the multiple entry points into a scene. It also feels natural.

My christmas game, which sadly I did not get released in time was Storyboard related and I was enjoying using Storyboard for it. I did have a bit of a learning curve getting the right bits in the create event and the right things in the enter event.

So if you're comfortable with Director, by all means use it. Want support and a few other nicer features, take a look at Storyboard.

@robmiracle well for me I feel more comfortable with Director class but there's this issue I have been dealing with for three days with my game and I'm unable to figure it out. Also it's been stressing me out this problem in which I'm trying to create my game.

Also I don't want to give up my project because of this big issue I'm facing with scene changing.

Well if its just a matter of removing stuff for Director, you have to remember anything put into "localGroup" will be removed automatically when the scene is removed. If you create something in a scene and DO NOT put it in localGroup it will hang around between scenes.

So if you have display objects that are not removing themselves automatically, the are not being inserted into "localGroup". Keep in mind you can put groups inside of groups. If you have a group that's not being removed make sure to put that group into localGroup.

If you are going to have a group that you cannot or will not put into "localGroup" then you have to manually remove it.

You need to provide a "clean" function:

1
2
3
4
5
6
7
8
9
10
11
12
function new(params)
   local localGroup = display.newGroup()
   ...
   all of your code to generate the scene
   ...
 
   function localGroup:clean()
       -- put any thing you need to manually remove here
       -- like event Listeners, timers, etc.
   end
   return localGroup
end

@robmiracle yeah I know what you mean but if you don't mind to taake a look at this

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
local group = display.newGroup()
 
local spawnBalloon = function()
 
ball = display.newImage( group, "balloon.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
if spawn == true then
end
end
 bTimer = timer.performWithDelay(500, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 

Which is better for you is only a question you can answer. Storyboard is officially supported however :)

Can you post the entire lua file that code is contained in?

ok here is the issue code

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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
 
module(..., package.seeall)
 
function new(params )
local localGroup = display.newGroup()
 
require( "ice" )
local physics = require("physics")
local ui = require("ui")
local gameUI = require("gameUI")
physics.start()
physics.setGravity(0, -1)
local scores = ice:loadBox( "scores" )
 
local high = scores:retrieve("best")
print(high)
 
display.setStatusBar( display.HiddenStatusBar )
 
local scoreText
local score = 0
local highscore 
local button1
local runMode = true
local spawn = true
local touch = true
local gameOver = false
 
 
local bkg = display.newImage( "bkg.png" )
bkg.x = 160; bkg.y = 240
localGroup:insert(bkg)
 
local score_txt =display.newText("Score: ",0,0,nil,25)
score_txt.x = 160; score_txt.y = 440
score_txt:setTextColor(0,0,0)
score_txt.text = "Score: ".. score
localGroup:insert(score_txt)
 
local spawnBall = function( event )
        local t = event.target
        local phase = event.phase
        if touch == true then
        if "began" == phase then
                t:removeSelf() -- destroy object
                score = score + math.random( 1000 )
                 score_txt.text = "Score: ".. score
        end
        -- Stop further propagation of touch event
        return true
end
end
 
 
local balls = {}
 
function localGroup:clean()
local group = display.newGroup()
 
local spawnBalloon = function()
 
ball = display.newImage( group, "balloon.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
if spawn == true then
end
end
 bTimer = timer.performWithDelay(500, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball2 = display.newImage( group, "balloon2.png" )
ball2.x = 60 + math.random( 160 )
ball2.y = 550
physics.addBody( ball2, { density=0.0, friction=0.1, bounce=0.1 } )
ball2:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball2
end
end
bTimer2 = timer.performWithDelay(800, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon3.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
end
end
bTimer3 = timer.performWithDelay(700, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon4.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
end
end
bTimer4 = timer.performWithDelay(600, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon5.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
end
end
bTimer5 = timer.performWithDelay(1100, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon6.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
end
end
bTimer6 = timer.performWithDelay(1300, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
local group = display.newGroup()
 
local spawnBalloon = function()
if spawn == true then
ball = display.newImage( group, "balloon7.png" )
ball.x = 60 + math.random( 160 )
ball.y = 550
physics.addBody( ball, { density=0.0, friction=0.1, bounce=0.1 } )
ball:addEventListener( "touch", spawnBall )
balls[#balls + 1] = ball
end
end
bTimer7 = timer.performWithDelay(900, spawnBalloon, -1)
 
local function delete()
for i=group.numChildren,1,-1 do
 local child = group[i]
if group[i].y < -100 then
display.remove(group[i]) -- dont know about this part, try it
end
end
end
 
Runtime:addEventListener("enterFrame", delete)
 
 
 
local bt = display.newImage ("pause.png")
bt.x = 290
bt.y = 30
localGroup:insert(bt)
 
local bt2 = display.newImage ("pauseOver.png")
bt2.x = bt.x
bt2.y = bt.y
bt2.isVisible = false
localGroup:insert(bt2)
 
local Pause = display.newText("Pause", 5, 0, "ArialRoundedMTBold", 30)
Pause.x = 160
Pause.y = 110
Pause:setTextColor(0,0,0)
Pause.isVisible = false
localGroup:insert(Pause)
 
local Resume = display.newText("Resume", 5, 0, "ArialRoundedMTBold", 25)
Resume.x = 160
Resume.y = 190
Resume:setTextColor(0,0,0)
Resume.isVisible = false
localGroup:insert(Resume)
 
local Quit = display.newText("Quit", 5, 0, "ArialRoundedMTBold", 25)
Quit.x = 160
Quit.y = 270
Quit:setTextColor(0,0,0)
Quit.isVisible = false
localGroup:insert(Quit)
 
--Function for pause button
local function done ()
physics.start()
spawn = true
touch = true
bt.isVisible = true
bt2.isVisible = false
Quit.isVisible = false
Resume.isVisible = false
Pause.isVisible = false
result = timer.resume( timerID )
end
Resume:addEventListener("tap", done)
 
 
 
local function onClick(e)
        if e.action == "clicked" then
                if e.index == 1 then
        director:changeScene ("balloon popper", "fade")
 
                        elseif e.index == 2 then
                                director:changeScene ("play", "fade")
                                        elseif e.index == 3 then
                                physics.start()
                                result = timer.resume( timerID )
                                 timer.resume(bTimer)
                  timer.resume(bTimer2)
                  timer.resume(bTimer3)
                  timer.resume(bTimer4)
                  timer.resume(bTimer5)
                  timer.resume(bTimer6)
                  timer.resume(bTimer7)
                end
        end
end
 
-- Display Alert
 
function bt:tap(e)
        local alert = native.showAlert("Paused Game", "Balloon Popper", {"Restart", "Main Menu", "Resume"}, onClick)
result = timer.pause( timerID )
physics.pause()
              timer.pause(bTimer)
                  timer.pause(bTimer2)
                  timer.pause(bTimer3)
                  timer.pause(bTimer4)
                  timer.pause(bTimer5)
                  timer.pause(bTimer6)
                  timer.pause(bTimer7)
end
bt:addEventListener("tap", bt)
 
 
local count = 60
 
local time = display.newText( "60", 5, 0, "ArialRoundedMTBold", 40)
time:setTextColor( 0, 0, 0 )
localGroup:insert(time)
 
local timeDelay = 700 
 
function time:timer( event )
        
        count = count -1
 
 
        self.text = count 
 
        if count <= 55 then
        
                director:changeScene ("popover")
                 timer.cancel(bTimer)
                  timer.cancel(bTimer2)
                  timer.cancel(bTimer3)
                  timer.cancel(bTimer4)
                  timer.cancel(bTimer5)
                  timer.cancel(bTimer6)
                  timer.cancel(bTimer7)
                timer.cancel( event.source)
                
        end
end
 
-- Register to call t's timer method 50 times
timerID = timer.performWithDelay( timeDelay, time, -1 )
 
 local highText = display.newText("", 0,0,nil,30)
        highText.x = display.contentWidth/2
        highText.y = display.contentHeight/2
        localGroup:insert(highText)
         highText.text = "HighScore: ".. scores:retrieve("best")
 
local function show_highScore()
 
 
        scores:storeIfHigher( "best", score )
scores:save()
        local highText = display.newText("", 0,0,nil,30)
        highText.x = display.contentWidth/2
        highText.y = display.contentHeight/2
   
        if score > high then
        highText.text = "HighScore: ".. scores:retrieve("best")
        else
    
         if score > high then
                print("new high score")
            highText.text = "HighScore: ".. scores:retrieve("best")     
        end
        end
        
end
 
 
 
timer.performWithDelay(60000, show_highScore, 1)
 
 
        
 
return localGroup
end

You have two problems that I see. The first one is you are reusing the same variable and function names over and over for unique entries.

You have 6 blocks that are trying to spawn your balloons.

When you go:

local group = display.newGroup()
... put some stuff in group

then later do:

local group = display.newGroup()
... put some stuff in group

You have basically written over the previous version. You do this 6 times. You also use the same function name: spawnBalloon to create 6 separate functions, but they all overwrite the previous ones.

These should be named:

local group1
local group2
local group3 etc.

and local spawnBalloons1 = function()
local spawnBalloons2 = function() etc.

You do the same thing with the 6 different delete() functions, they should be named delete1(), delete2() etc. And when you set up the event listener, for "enterFrame", use delete1, delete2 etc.

The contents of the delete function need to remove from the specific group...

Next your spawn routine never actually puts anything into "group".

So all these balloons are being spawned and never put into a group. Finally the "group"'s are not being put into localGroup so switching scenes won't remove anything. To compound matters, your timers that you're using to create the objects are also never being canceled, so if the player can switch to another scene those timers are still going to try and fire. They need to be cancelled manually in your localGroup:clean() function (which really should be at the bottom because of the forward declarations....)

Oh and the balloon popper.... you probably should not have a space in the string or the filename. Make sure you have a balloonpopper.lua file and that the string is "balloonpopper"

that should fix that problem.

@robmiracle so how would I put localGroup:clean() can you show me how would that look like for the balloons

@robmiracle thanks for help alot :)

You have a localGroup:clean() at the top. Unfortunately the code inside it looks like you want to spawn more balloons rather than cleaning up the level. Move it to the bottom, just above the "return localGroup", strip all of the code out of it.

the contents should be something like this at the end:

1
2
3
4
5
6
7
8
9
10
11
12
...
 
    function localGroup:clean()
        if bTimer then 
            timer.cancel(bTimer); 
            bTimer = nil 
        end
        -- repeat the above 4 lines for each timer changing the variables
    end
 
    return localGroup
end -- end of the new() function

@robmiracle hey did you get my email

No, not yet!

@robmiracle oh becuase I sent it a while ago you should see my email is closely related to this username I'm using for corona

I would think that in theory, the Storyboard API would be better since it could technically be native, although I'm not sure that's the case right now.

Any insight devs?

Still haven't gotten the email.

@robmiracle ok then I will resend it from the website you gave me

I sent the message introducing myself

@robmiracle I've sent the email to did u get it

no... try rob.miracle at gmail dot com

@robmiracle ok I sent the message a while ago did u get my message?

My personal opinion base on your question (which is better) I would go with Director Class very simple been used for a while so there is a lot of Q&A and I have worked on a lot of different games and all use director class and it does the job perfectly and hopefully newest version comes out soon which will bring new stuff.

I've tried both in the exact same app, and director is faster. Storyboard seems to have a split-second lag that is just barely noticeable to the user, but it gets annoying if you're doing a lot of screen switching. Director is pretty much instant with no lag at all.

views:1992 update:2011/12/29 9:44:01
corona forums © 2003-2011