Hey guys I created a thread on this before but it seems to have got lost with the new look and I can no longer see it, so im creating again.
The problem was getting a scroller function to destroy scroll Event Listeners as they go off stage.
Right now im getting the “attempt to compare nil with number” error.
The error occurs on line 2 according to the terminal.
function scrollCloud(self, event) if self.x \< -477 then display.remove(self) Runtime:removeEventListener("enterFrame", self) print("destroyed") else self.x = self.x - self.speed end end
For reference these are the Event listeners for scrollCloud
cloud1.enterFrame = scrollCloud Runtime:addEventListener("enterFrame", cloud1) cloud2.enterFrame = scrollCloud Runtime:addEventListener("enterFrame", cloud2) cloud3.enterFrame = scrollCloud Runtime:addEventListener("enterFrame", cloud3)
Any ideas on fixing this?
Thanks