简体   繁体   中英

Corona sdk physics doesn't work

I have problem with implementing physics into my code.

local physics = require( "physics" )
physics.start()


local safe = display.newImageRect("safe.png",100,100)
safe.x=display.contentCenterX+80

safe.y=display.contentCenterY

safe.height=100

safe.width=100

physics.addBody( safe, { density=1.0, friction=1 } )

Nothing happens, my image is on fixed position and doesn't move at all. Does any one have any ideas what should I do to make that code work? Thanks in advance!

This is how you have to add an object to physics,

local physics = require( "physics" )
physics.start()

physics.setGravity( 0, 6 )


physics.addBody( safe, "static", { friction=0.5, bounce=0.3 } )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM