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

7 replies [Last post]
sebitttas's picture
sebitttas
User offline. Last seen 38 min 37 sec ago. Offline
Joined: 17 Jan 2011

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

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

Also I heard people using story Board you think I by changing to story Board would solve my problem

Replies

sebitttas's picture
sebitttas
User offline. Last seen 38 min 37 sec ago. Offline
Joined: 17 Jan 2011

I've fixed it

mwlake08
User offline. Last seen 1 day 3 hours ago. Offline
Joined: 3 Nov 2011

Would you like to share your fix?

jeff472's picture
jeff472
User offline. Last seen 3 hours 56 min ago. Offline
Joined: 2 Dec 2011

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?

sebitttas's picture
sebitttas
User offline. Last seen 38 min 38 sec ago. Offline
Joined: 17 Jan 2011

I forgot were but all I know this problem was solved a long time ago.

albert.chan8
User offline. Last seen 13 weeks 4 days ago. Offline
Joined: 5 Aug 2011

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

sharp1959's picture
sharp1959
User offline. Last seen 18 hours 45 min ago. Offline
Joined: 28 Nov 2011

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

Larry

albert.chan8
User offline. Last seen 13 weeks 4 days ago. Offline
Joined: 5 Aug 2011

Thanks helps ..... its working fine now after I watch the tutorial.
Thanks!

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.