ball not falling

In my app I add physics code to my ball image here’s the code:

  – display ball image
 local ball = display.newImage( “ball.png” )
 ball.x = 145; ball.y = 200
 
 – add physics to the ball
 physics.addBody ( ball, { friction=0.5, bounce=2 } ) 
 

:that is the end of the codeWhen I relaunch my ball just stands still floating in the air please help!

Can you copy/pasted your exact code using the <> button in bar with the bold, italics, etc.?

Rob

exect code:

 – display ball image
 local ball = display.newImage( “ball.png” )
 ball.x = 145; ball.y = 200
 
 – add physics to the ball
 physics.addBody ( ball, { friction=0.5, bounce=2 } )

As Rob stated we will need to see more code and in the future use LUA Tags.

Did you start the physics engine?

Have you set the gravity?

physics.start() physics.setGravity(0, 7)

No I didn’t set gravity . I thought turning on physics took care of that . thank you so much

Order matters in Lua.

local physics = require( "physics" ) physics.start() &nbsp; -- display ball image &nbsp;local ball = display.newImage( "ball.png" ) &nbsp;ball.x = 145; ball.y = 200 &nbsp; &nbsp;-- add physics to the ball &nbsp;physics.addBody ( ball, { friction=0.5, bounce=2 } )

You have to include the physics library.  Then you have to start physics before you can add bodies.  The gravity will default to earth standard gravity.  You only need to change it if you want something other than 9.8 meters per second per second.

Rob

Can you copy/pasted your exact code using the <> button in bar with the bold, italics, etc.?

Rob

exect code:

 – display ball image
 local ball = display.newImage( “ball.png” )
 ball.x = 145; ball.y = 200
 
 – add physics to the ball
 physics.addBody ( ball, { friction=0.5, bounce=2 } )

As Rob stated we will need to see more code and in the future use LUA Tags.

Did you start the physics engine?

Have you set the gravity?

physics.start() physics.setGravity(0, 7)

No I didn’t set gravity . I thought turning on physics took care of that . thank you so much

Order matters in Lua.

local physics = require( "physics" ) physics.start() &nbsp; -- display ball image &nbsp;local ball = display.newImage( "ball.png" ) &nbsp;ball.x = 145; ball.y = 200 &nbsp; &nbsp;-- add physics to the ball &nbsp;physics.addBody ( ball, { friction=0.5, bounce=2 } )

You have to include the physics library.  Then you have to start physics before you can add bodies.  The gravity will default to earth standard gravity.  You only need to change it if you want something other than 9.8 meters per second per second.

Rob