我是Corona和Lua的新手.我有以下问题:
我有一个cake
带有这些物理参数的对象(并不重要):
["cake1"] = {
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -21, 62.5 , -36, 62.5 , -50, 55.5 , -58.5, 46 , -36, -38.5 , 57, -40.5 , 57.5, 34 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -7.5, -63 , -13, -61.5 , -12, -64.5 , -8, -64.5 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -12, -64.5 , -13, -61.5 , -17.5, -56 , -21, -52.5 , -18.5, -60 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -47, -37.5 , -58.5, 46 , -58.5, -33 , -53, -37.5 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -26, -52.5 , -21, -52.5 , -18.5, -52 , -9, -47.5 , -6.5, -41 , -36, -38.5 , -34.5, -46 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -36, -38.5 , -58.5, 46 , -47, -37.5 , -42, -39.5 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -6.5, -41 , -9, -47.5 , -6.5, -44 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { 25, -40.5 , 7, -40.5 , 17, -42.5 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { 48, -42.5 , 57, -40.5 , 25, -40.5 , 32, -42.5 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { -18.5, -52 , -21, -52.5 , -17.5, -56 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { 7, -40.5 , -36, -38.5 , -6.5, -41 }
}
,
{
pe_fixture_id = "", density = 2, friction = 0, bounce = 0,
filter = { categoryBits = 1, maskBits = 65535, groupIndex = 0 },
shape = { 25, -40.5 , -36, -38.5 , 7, -40.5 }
}
}
Run Code Online (Sandbox Code Playgroud)
当我将它插入到场景中时,我得到以下结果:
该cake
太大,所以我用cake1:scale(0.5,0.5)
改变自己size.The问题是,物理学并没有自动更改应用到其新的大小,其结果是:
有没有简单的方法来改变对象的大小,物理自动适应新的大小,或者我必须重写它们?
Kri*_*lim 11
你是否正在使用物理编辑器......?
然后scaleFactor
提供.您可以使用此比例因子为物体指定物理,如下所示:
local scaleFactor = 1.0
local physicsData = (require "shapedefs").physicsData(scaleFactor)
local shape = display.newImage("objectname.png")
physics.addBody( shape, physicsData:get("objectname") )
Run Code Online (Sandbox Code Playgroud)
当你改变scaleFactor时,物理区域的大小会自动改变.
有关详细信息,请访问:http://velluminteractive.com/advanced-physics-bodies-with-physics-editor-and-corona-sdk/