How can I remove each circle that spawns when it passes a certain point?

This doesn’t work. It prints my.name but It doesn’t remove the circle

startBtn = function (event) if event.phase == "began" then Runtime:addEventListener( "accelerometer", onTilt ) scorerTimer = timer.performWithDelay(250,updateScore,0) scoreNumber.alpha=1 playgame:removeEventListener("touch",startBtn) playSound("click") transition.to(playgame,{time=200,alpha=0}) transition.to(SQUARES,{time=200,alpha=0}) transition.to(scoresign,{time=200,alpha=1}) transition.to(player,{time=300,alpha=1,y=H1\*0.6}) local function spawnCircle(self,event) local myCircle = display.newRect(enemyGroup,20,20,20,20 ) myCircle.x = math.random(W1\*0, W1\*1) myCircle:setFillColor(128/255,128/255,128/255) myCircle.y = H1\*-0.2 myCircle.speed = -3 physics.addBody(myCircle,"static",{radius=12.5,bounce=1}) transition.to(myCircle,{time=999999,rotation=math.random(-99999,99999)}) local function removerrrr(self,event) if myCircle.y \> 0.5 then print(my.name) display.remove(self) return true end end Runtime:addEventListener("enterFrame",removerrrr) timer.performWithDelay(500,removerrrr,0) increaseSpeed = function (event) myCircle.speed = myCircle.speed -0.5 end timer.performWithDelay(250,increaseSpeed,0) local function backgroundScroll(self,event) self.y = self.y - self.speed if self.y \> W1\*0.2 then print(my.name) end end Runtime:addEventListener("enterFrame", myCircle) myCircle.enterFrame=backgroundScroll end circlespawning=timer.performWithDelay(200,spawnCircle,0) end end

If you print out the value of self and event in your removerrr() function you will find that self is actually your event parameter and event is nil.  You have it programmed like it’s something attached to an object (i.e. expecting it to pass a reference to itself  to the function).  Neither the Runtime enterFrame or the timer pass in the object to work on.

I’m assuming you’re creating multiple circles that you want to be able to remove.  You should be storing a reference to these in a table and then looping over them in your enterFrame to see if it’s past your threshold.

Rob

Alright Ill see what I can do I am 16 and have been using Corona SDK for less than a year, I started in November. I struggle ha.

If you print out the value of self and event in your removerrr() function you will find that self is actually your event parameter and event is nil.  You have it programmed like it’s something attached to an object (i.e. expecting it to pass a reference to itself  to the function).  Neither the Runtime enterFrame or the timer pass in the object to work on.

I’m assuming you’re creating multiple circles that you want to be able to remove.  You should be storing a reference to these in a table and then looping over them in your enterFrame to see if it’s past your threshold.

Rob

Alright Ill see what I can do I am 16 and have been using Corona SDK for less than a year, I started in November. I struggle ha.