如何在Corona中使不同类型的物体以相同的速度下降

时间:2013-07-26 13:39:39

标签: corona physics

我有不同的图像作为显示对象,我希望它们在物理学中以相同的速度下降。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

物体的密度必须完全相同

physics.addBody(object,"dynamic",{density = 1)

试试这段代码

local object1 = display.newRect(0,0,math.random(10,100),math.random(10,100))
object1.x = 100
object1.y = 0
physics.addBody(object1,"dynamic",{bounce = 1, friction = 0, density = 1})

local object2 = display.newRect(0,0,math.random(10,100),math.random(10,100))
object2.x = 200
object2.y = 0
physics.addBody(object2,"dynamic",{bounce = 1, friction = 0, density = 1})

由于密度,随机尺寸但速度相同。