Physics causing simulator to crash

I am starting an application and having a major issue that I cannot resolve. I have tried reinstalling corona, different display objects, but no matter what, the simulator crashes. Here is the error I receive:

/Applications/CoronaSDK/Corona Terminal: line 9: 1528 Bus error: 10 “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout

[Process completed]
Here is the code that causes it:

  
local physics = require "physics"  
  
local w = display.contentWidth  
local h = display.contentHeight  
  
local zone1 = display.newRect(0, 0, 40, 180)  
zone1.x = 0 + zone1.width / 2  
zone1.y = h / 2  
  
physics.addBody( zone1, "static", {density = 0.0, friction = 0.0, bounce = 0.0})  

I CANNOT get this to stop crashing, am I doing something wrong? Thanks in advance! [import]uid: 9968 topic_id: 15982 reply_id: 315982[/import]

Hey,

Have a look at the sentence of the require “physics” you wrote. Its missing the ( ).

I am new here but also you could have a look at “start” the physics like this example below:

[lua]-- begin by turning on physics and setting gravity
local physics = require ( “physics” )
physics.start( true )
physics.setGravity (0, 9.8)[/lua]

Hope that helps and sorry if not. Just trying to give some idea.
Regards,
Rodrigo. [import]uid: 89165 topic_id: 15982 reply_id: 59252[/import]

You did not give
[lua]physics.start()[/lua]

[import]uid: 64174 topic_id: 15982 reply_id: 59265[/import]

The above answers were correct, you need to start physics and you need to set the gravity, otherwise yes, it will fail.

[lua]local physics = require ( “physics” )
physics.start()
physics.setGravity( 0, 8.5 )

local w = display.contentWidth
local h = display.contentHeight

local zone1 = display.newRect(0, 0, 40, 180)
zone1.x = 0 + zone1.width / 2
zone1.y = h / 2

physics.addBody( zone1, “static”, {density = 0.0, friction = 0.0, bounce = 0.0})[/lua]

Copy and paste that, it should work.

Peach :slight_smile: [import]uid: 52491 topic_id: 15982 reply_id: 59274[/import]

not sure about setting the gravity, as that is a default value, however starting physics before any physics related function is used is a must.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15982 reply_id: 59293[/import]