I need help removing off screen objects!

Help ! ;3

So i need a way to track the y  of a specific object i have attempted to do this by myself multi able times and failed. i don’t have much to show but alot of nonworking code. This is what i have: 

 local function poof(self, event)

if(self.y == nil) then

return

end

 

if(self.y > display.contentHeight + 50) then

death:removeEventListener( “enterFrame”, self )

self:removeSelf()

print(“Ghost”)

end

end

 

 

 

    elseif(math.random(1,10) > 3) then

death = display.newImage(“Death.png”,startX, -300)

physics.addBody( death )

death.enterFrame = poof

death:addEventListener( “eneterFrame”, poof )

death:addEventListener( “touch”, deathTouched )

 

 

In short i need a way    elseif(math.random(1,10) > 3) then

death = display.newImage(“Death.png”,startX, -300)

physics.addBody( death )

death.enterFrame = poof

death:addEventListener( “eneterFrame”, poof )

death:addEventListener( “touch”, deathTouched )

 

In short i have a method of removing all objects that have gone off the screen but i need to know when a specific object has left the screen this way i can make the player lost life ect ect.

Any help would be amazing

Thanks

Pronoun

Hello @Dupheadss. A couple of administrative things. First and most importantly please use code tags such as clicking on the blue <> button in the edit bar (with Bold and Italic) and paste your code into the window that pops up. It will make your code much easier to read and increase the chance the community will try and help you.

Secondly please try and avoid adding styles to your text. We like plain boring text. Supersizing “specific” isn’t going to help you get answers or is the blue bar at the top. It’s okay to bold things that should be bold, or italicize things that need italics but even those should be use sparingly and when needed for clarity.

Now to your problem. If the code above is a copy/paste from your editor then this line is a problem:

death:addEventListener( "eneterFrame", poof )

it should be

death:addEventListener( "enterFrame", poof )

note the extra “e” you added.

Rob

Thanks for the response and i’ll be sure to keep that in mind for future posts!

I’ve fixed that error in the code however it still does not help me. Basically objects are falling from the top of the screen the player has to tap them. If one of the objects get to the bottom(off) the screen the player losers. Now i can remove all objects after they leave the screen but i am not sure how to know if a specific object has fallen off the screen. Anyone other words if a  bomb falls off the screen do nothing if a balloon falls off the screen subtract points.

Thanks

Pronoun

Hello @Dupheadss. A couple of administrative things. First and most importantly please use code tags such as clicking on the blue <> button in the edit bar (with Bold and Italic) and paste your code into the window that pops up. It will make your code much easier to read and increase the chance the community will try and help you.

Secondly please try and avoid adding styles to your text. We like plain boring text. Supersizing “specific” isn’t going to help you get answers or is the blue bar at the top. It’s okay to bold things that should be bold, or italicize things that need italics but even those should be use sparingly and when needed for clarity.

Now to your problem. If the code above is a copy/paste from your editor then this line is a problem:

death:addEventListener( "eneterFrame", poof )

it should be

death:addEventListener( "enterFrame", poof )

note the extra “e” you added.

Rob

Thanks for the response and i’ll be sure to keep that in mind for future posts!

I’ve fixed that error in the code however it still does not help me. Basically objects are falling from the top of the screen the player has to tap them. If one of the objects get to the bottom(off) the screen the player losers. Now i can remove all objects after they leave the screen but i am not sure how to know if a specific object has fallen off the screen. Anyone other words if a  bomb falls off the screen do nothing if a balloon falls off the screen subtract points.

Thanks

Pronoun