How to repeat a fall.

I have a knife falling to the bottom of the screen and then gone completely but how can I repeat this action after it leaves the screen endless times?

local knife = display.newImage( “knife.png” )

knife:translate (130,90)

knife:scale (0.5,0.5)

local physics = require( “physics” )

physics.addBody( knife, “dynamic”, {bounce = 0.95} )

knife.gravityScale = 0.25

knife.isSleepingAllowed = false

This is the code I have.

There are many ways.  Here are three:

  1. Use a timer and destoy the object, then use another timer to spawn a new one.

  2. Ue a timer to move the object back to the top of the screen after a fixed period (remember to reset the velocity to 0)

  3. Use a sensor object covering the screen and have the falling object move back to the top of the screen when the collision with the sensor object ends.  Again, reset the velocity (but one frame later).

bonus method:

  1. Use an enterframe listener on the object and move it to the top of the screen once Y is > than the bottom of the screen.  Again, reset the velocity.

Here is one way to make objects spawn at the top, continue spawning, and to remove objects that make it to the bottom of the screen:

https://github.com/roaminggamer/RG_FreeStuff/tree/b68f5fce9934393f5b315f7c8b1d2882ee66eb2d/AskEd/2014/06/balloonPop

Hi again.  Are you taking a class?  I ask because I saw another question just like this and thought it was weird.

roaming gamer, I am actually just teaching myself by making a game so learning as I go along instead of learning first then doing. I will check out the github you sent me and let you know if it works.

Thanks

Roaming Gamer, Thank you so much I just have one query; how do I make the images smaller?

Also is there a way to block some of the knifes from coming in a certain area?

Also how do I make it bounce off a static object?

To make a bounce off a static object, you need to create a dynamic physics body on that object:

Then you could make it bouncy:

physics.addBody(object, "dynamic",{bounce = 3})

To make the images smaller just resize them on your computer, you could find tutorials online if you don’t already know.

And yes there is a way to block off the knives, create an invisible object with physics.

Hey.  I was digging through my many examples and found another that might be useful:

https://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015/05/fallingObjects

https://www.youtube.com/watch?v=ceztetRwND0&feature=youtu.be

Don’t forget I’ve got a TON of examples here:

https://github.com/roaminggamer/CoronaGeek

and here:

https://github.com/roaminggamer/RG_FreeStuff

There are many ways.  Here are three:

  1. Use a timer and destoy the object, then use another timer to spawn a new one.

  2. Ue a timer to move the object back to the top of the screen after a fixed period (remember to reset the velocity to 0)

  3. Use a sensor object covering the screen and have the falling object move back to the top of the screen when the collision with the sensor object ends.  Again, reset the velocity (but one frame later).

bonus method:

  1. Use an enterframe listener on the object and move it to the top of the screen once Y is > than the bottom of the screen.  Again, reset the velocity.

Here is one way to make objects spawn at the top, continue spawning, and to remove objects that make it to the bottom of the screen:

https://github.com/roaminggamer/RG_FreeStuff/tree/b68f5fce9934393f5b315f7c8b1d2882ee66eb2d/AskEd/2014/06/balloonPop

Hi again.  Are you taking a class?  I ask because I saw another question just like this and thought it was weird.

roaming gamer, I am actually just teaching myself by making a game so learning as I go along instead of learning first then doing. I will check out the github you sent me and let you know if it works.

Thanks

Roaming Gamer, Thank you so much I just have one query; how do I make the images smaller?

Also is there a way to block some of the knifes from coming in a certain area?

Also how do I make it bounce off a static object?

To make a bounce off a static object, you need to create a dynamic physics body on that object:

Then you could make it bouncy:

physics.addBody(object, "dynamic",{bounce = 3})

To make the images smaller just resize them on your computer, you could find tutorials online if you don’t already know.

And yes there is a way to block off the knives, create an invisible object with physics.

Hey.  I was digging through my many examples and found another that might be useful:

https://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015/05/fallingObjects

https://www.youtube.com/watch?v=ceztetRwND0&feature=youtu.be

Don’t forget I’ve got a TON of examples here:

https://github.com/roaminggamer/CoronaGeek

and here:

https://github.com/roaminggamer/RG_FreeStuff