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? [import]uid: 17058 topic_id: 19484 reply_id: 319484[/import]

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 [import]uid: 84539 topic_id: 19484 reply_id: 75152[/import]

@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 [import]uid: 17058 topic_id: 19484 reply_id: 75154[/import]

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. [import]uid: 84539 topic_id: 19484 reply_id: 75155[/import]

i just used to Director class, it very simple and very awesome
for now i prefer to stick with it [import]uid: 16142 topic_id: 19484 reply_id: 75156[/import]

Good luck… [import]uid: 84539 topic_id: 19484 reply_id: 75157[/import]

@darkconsoles thxs for advice :slight_smile:

@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.

[import]uid: 17058 topic_id: 19484 reply_id: 75159[/import]

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 [import]uid: 84539 topic_id: 19484 reply_id: 75160[/import]

@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.
[import]uid: 19626 topic_id: 19484 reply_id: 75162[/import]

@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. [import]uid: 17058 topic_id: 19484 reply_id: 75164[/import]

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

[code]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)
[/code]

This part is what I mean about group when items spawn multiple time and be remove in certain height how would I have them not appear in the next scene.

doing localGroup:insert(ball) does not work
group:insert(ball) does not work
localGroup:insert(group) does not work
group:insert(group) does not work

[import]uid: 17058 topic_id: 19484 reply_id: 75170[/import]

Which is better for you is only a question you can answer. Storyboard is officially supported however :slight_smile: [import]uid: 84637 topic_id: 19484 reply_id: 75171[/import]

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:

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  
  

That should take care of cleaning up the scene. Is this not working for you?
[import]uid: 19626 topic_id: 19484 reply_id: 75166[/import]

Can you post the entire lua file that code is contained in?
[import]uid: 19626 topic_id: 19484 reply_id: 75173[/import]

ok here is the issue code

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  

Also when I test this on a real device I get a director error saying failed to excute function on balloon popper meaning this scene. I only get this error on a real device not in the simulator [import]uid: 17058 topic_id: 19484 reply_id: 75176[/import]

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…)

[import]uid: 19626 topic_id: 19484 reply_id: 75180[/import]

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. [import]uid: 19626 topic_id: 19484 reply_id: 75181[/import]

@robmiracle so how would I put localGroup:clean() can you show me how would that look like for the balloons [import]uid: 17058 topic_id: 19484 reply_id: 75182[/import]

@robmiracle thanks for help alot :slight_smile: [import]uid: 17058 topic_id: 19484 reply_id: 75187[/import]

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:

...  
  
 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  

But this isn’t going to fix your balloon cleanup until you properly use the right variable names and put your display objects into groups…

This code needs a lot of work and I can do a lot to improve this for you. Since its majorly off topic, contact me at rob at omnigeekmedia dot com and we can talk about it some more.

[import]uid: 19626 topic_id: 19484 reply_id: 75189[/import]