can't spawn bonus object

I know this is because of my poor coding skills but can someone help me,I’m trying to make it when the player collides with object2, 15 bonus objects will spawn. But I’m doing something wrong >:(

[code]
function objectSpawn()
object = display.newImage(“object.png”)
object.x = 510
object.y = math.random(0,280)
localGroup:insert(object)
transition.to (object, {time=3500, x=-50})
physics.addBody(object, {bounce=0.6})
object.angularVelocity = math.random(-200,200)
object.myName = “object”
object.collision = onobjectCollision
object:addEventListener(“collision”, object)

end

function onobjectCollision ( self,event )
if ( event.phase == “began” ) then
if ( self.myName == “object” ) then
if ( event.other.myName == “player” ) then
playGood()
score.setScore( score.getScore() + 25 )
self:removeSelf()
elseif (event.other.myName == “leftwall”) then
self:removeSelf()
end
end
end
end

timer1 = timer.performWithDelay( 1000, objectSpawn, 0 )
function object2Spawn()
object2 = display.newImage(“object2.png”)
object2.x = 510
object2.y = math.random(0,280)
localGroup:insert(object2)
transition.to (object2, {time=3500, x=-50})
physics.addBody(object2, {bounce=0.6})
object2.angularVelocity = math.random(-200,200)
object2.myName = “object2”
object2.collision = onobject2Collision
object2:addEventListener(“collision”, object2)

end

function onobject2Collision ( self,event )
if ( event.phase == “began” ) then
if ( self.myName == “object2” ) then
if ( event.other.myName == “player” ) then
playGood()
self:removeSelf()

– Bonus Object
function bonusspawn(event)
bonus = display.newImage(“bonusobject.png”)
bonus.x = 510
bonus.y = math.random(0,280)
localGroup:insert(bonus)
transition.to (bonus,{timer=3500, x=-50})
physics.addBody (bonus, {bounce=0.6})
bonus.angularVelocity -math.random(-200,200)
bonus.myName = “bonus”
bonus.collision = onBonusCollision
bonus:addEventListener(“collision”, bonus)
end
function onBonusCollision (self,event)
if event.phase == “began” then
if self.myName == “bonus” then
if event.other.myName == “player” then
playGood()
score.setScore( score.getScore() + 50 )
self:removeSelf()
elseif event.other.myName == “leftwall” then
self:removeSelf()
end
end
end
end
bonustimer = timer.performWithDelay( 300, bonusspawn, 15 )

elseif (event.other.myName == “leftwall”) then
self:removeSelf()
end
end
end
end

timer2 = timer.performWithDelay( 1000, object2Spawn, 0 ) [import]uid: 114389 topic_id: 26494 reply_id: 326494[/import]

Hey there - have you tried putting a few print statements to isolate which line the issue is on?

I assume no error messages - but nothing spawns at all, or only one bonus object? Details, please? :slight_smile: [import]uid: 52491 topic_id: 26494 reply_id: 107574[/import]

The screen is just black and says there’s an error in my menu which I know it’s not that. I’m just trying to spawn 1 object 15 times every time “object2” is collected. I tried to do it starting on line 54. [import]uid: 114389 topic_id: 26494 reply_id: 107841[/import]

What error is being printed in the terminal? [import]uid: 52491 topic_id: 26494 reply_id: 107950[/import]

I get the Director Error on line 135. But I know that can’t be the problem. [import]uid: 114389 topic_id: 26494 reply_id: 108350[/import]

Is that your only error, or are there others being printed as well? For Director related errors unfortunately we’re unable to assist as is 3rd party, however there is a subforum for Director issues. [import]uid: 52491 topic_id: 26494 reply_id: 108448[/import]