Help with physics.

Ok so i am trying to get an image to fall from the top, outside of the screen; so like above the screen so you cant see it. And i want it go from there to outside the bottom; so below the screen. And the problem i am having is i cant figure out how to do it, i have searched it, read the resources and i cant figure it out. If someone could link me to a tutorial or help me out with the code i would greatly appreciate it. [import]uid: 69054 topic_id: 18664 reply_id: 318664[/import]

oops i accidentally posted another one of these too. [import]uid: 69054 topic_id: 18664 reply_id: 71704[/import]

Hey there, here’s a basic example;

[lua]require ( “physics” )
physics.start()
physics.setGravity( 0, 7.5 )

local circle = display.newCircle( 160, -100, 30 )
physics.addBody(circle, “dynamic”)[/lua]

I deleted the other thread; don’t worry about it, so long as you aren’t deliberately making multiples no one has a problem with it :wink:

Peach :slight_smile: [import]uid: 52491 topic_id: 18664 reply_id: 71783[/import]

OK thank you for that, but also how would i make it go like randomly and have more than one? Kind of like a snow flake effect type thing. [import]uid: 69054 topic_id: 18664 reply_id: 71785[/import]

Yay i seem to have gotten it they way i wanted it by using the code you gave me (thank you) and adding some more and modifying the one you gave me. Here is the code i am using at the moment:

[code]
local physics = require(“physics”);
physics.start();

require ( “physics” )
physics.start()
physics.setGravity( 0, 7.5 )

local function spawnCircle()
local Circle = display.newCircle( 160, -100, 30 )
Circle:setReferencePoint(display.TopReferencePoint);
physics.addBody(Circle, “dynamic”)

end

tmr = timer.performWithDelay(100, spawnCircle, 400);
[/code] [import]uid: 69054 topic_id: 18664 reply_id: 71795[/import]

This is good but you should also make sure you get rid of the objects - otherwise they fall off the screen and keep going :wink:

You could put a “floor” below where you can on the screen and then on collision remove the snowflakes.

Peach :slight_smile: [import]uid: 52491 topic_id: 18664 reply_id: 71809[/import]

Yes good suggestion thank you, i was just a few minutes ago when i ran it noticed that they kept going down and made the animation very laggy i will go do that now, thanks. [import]uid: 69054 topic_id: 18664 reply_id: 71940[/import]

No worries, Corona for Newbies Part 4 has a tutorial on collision detection if you need it; http://techority.com/2011/06/19/corona-for-newbies-part-4-physics/

Peach :slight_smile: [import]uid: 52491 topic_id: 18664 reply_id: 72054[/import]

IÂ?m impressed, I must say. Really not often do I encounter a blog thatÂ?s both educative and entertaining, and let me tell you, you’ve hit the nail on the head. Your thought is excellent; the issue is something that not enough people are talking intelligently about. I am very blissful that I stumbled throughout this in my seek for one thing relating to this.
Buy ativan without prescription goose Valium puerility Levitra friedreich [import]uid: 135934 topic_id: 18664 reply_id: 96597[/import]