DIRECTOR Class - ERROR failed to excute function on 'balloon popper'

I keep on getting this error in the director class everytime I test it on my iPhone. everytime I get the error the scene won’t change after it has counted back 10 seconds.

This the code example

[code] module(…, package.seeall)

function new()
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 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 = {}

local group = display.newGroup()

local spawnBalloon = function()

ball = display.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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.newRect(group, 50, 50, 100, 100)
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 hasRun = 0

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
hasRun = hasRun +1

self.text = count

if hasRun >= 10 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[/code]

Also I heard people using story Board you think I by changing to story Board would solve my problem [import]uid: 17058 topic_id: 19456 reply_id: 319456[/import]

I’ve fixed it [import]uid: 17058 topic_id: 19456 reply_id: 75882[/import]

Would you like to share your fix? [import]uid: 101897 topic_id: 19456 reply_id: 83303[/import]

Director errors (IME) are usually nothing to do with Director, but problems in your own code which make the create and unload routines fail.
The important thing when you see a Director ‘error’ is to look in the terminal output and see which module and line reports an error.

What did it say in terminal? [import]uid: 108660 topic_id: 19456 reply_id: 83305[/import]

I forgot were but all I know this problem was solved a long time ago. [import]uid: 17058 topic_id: 19456 reply_id: 83337[/import]

hi I getting the same error

can anyone help me please

module (…,package.seeall)
function new()

local splashSGroup = display.newGroup()

local background = display.newImage(“Graphics/splash.png”)
local touchToBeginR = display.newImage(“Buttons/touchtoBeginR.png”)
touchToBeginR.x = display.contentCenterX
touchToBeginR.y = display.contentCenterY + 300

touchToBeginR.scene =“menu”

splashSGroup:insert(background)
splashSGroup:insert(touchToBeginR)

touchToBeginR.addEventListener(“touch”, changeScene)

return splashSGroup
end [import]uid: 81215 topic_id: 19456 reply_id: 85541[/import]

Hi Albert,

I think your missing some code:

Like Director:changeScene…
Here is a good tutorial on Director Class
by: Dr. Rafael Hernandez

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

Hope that helps…:wink:
Larry
[import]uid: 107633 topic_id: 19456 reply_id: 85546[/import]

Thanks helps … its working fine now after I watch the tutorial.
Thanks! [import]uid: 81215 topic_id: 19456 reply_id: 85771[/import]