how do I stop this from spawning circles?!?!?

local function spawncatHead()

local myCircle = display.newRect(50,50,50, 25 )

myCircle.x = math.random(0, W1) 

myCircle.y = H1/-2

myCircle:setFillColor(20,50,100 )

myCircle.speed = -3

physics.addBody(myCircle,“static”,{radius=25,bounce=1})

   local function backgroundScroll(self,event)

   if self.y > 100000 then

   self.y = 640

   else

   self.y = self.y - self.speed

   end

   end

Runtime:addEventListener(“enterFrame”, myCircle)

myCircle.enterFrame=backgroundScroll

local function onCollision(event)

if event.phase == “began” then

physics.stop()

player:pause()

background1.speed=0

background.speed=0

myCircle.speed=0

Runtime:removeEventListener(“enterFrame”,myCircle)

fadeover = display.newImageRect(frontGroup,“fadeover.png”,320,568)

fadeover.x = W1 / 2 

fadeover.y = H1 / 2

fadeover.alpha=0

transition.to(fadeover, {time=200,alpha=0.3})

Gameovertitle=display.newText(textFrontGroup, “GameOver”,W1/2,H1/2-400,“eraser”, 50 )

Gameovertitle.alpha=0

transition.to(Gameovertitle, {time=200,y=W1/4+50,alpha=1})

playAgain=display.newText(textFrontGroup, “PlayAgain”,W1/2,H1/2+200,“eraser”, 50 )

playbtn = function (event)

if event.phase == “began” then

transition.to(playAgain, {time=200,y=H1/4+200,alpha=0})

transition.to(Gameovertitle, {time=200,y=H1/2-400,alpha=0})

fadeover.alpha=0

background1.speed=-3

background.speed=-3

myCircle.alpha=0

player:play()

end

end

playAgain:addEventListener(“touch”,playbtn)

playAgain.alpha=0

transition.to(playAgain, {time=200,y=W1/4+200,alpha=1})

end

end

Runtime:addEventListener(“collision”,onCollision)

end

catSpawn = timer.performWithDelay(1000,spawncatHead,0)

EDIT I NEED THE CIRCLES TO STOP SPAWNING ON COLLISION 

You’re likely to get help faster if you put code tags around your code – really hard to skim it otherwise.

Use the little < > image in the toolbar – a window pops up and you can paste your properly formatted code into that. Everybody will thank you for that. :slight_smile:

 Jay

EDIT I NEED THE CIRCLES TO STOP SPAWNING ON COLLISION 

You’re likely to get help faster if you put code tags around your code – really hard to skim it otherwise.

Use the little < > image in the toolbar – a window pops up and you can paste your properly formatted code into that. Everybody will thank you for that. :slight_smile:

 Jay