2

我是 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  }
                    }



        }

当我将它插入场景时,我得到以下结果:

在此处输入图像描述

cake太大了,所以我用来cake1:scale(0.5,0.5)改变他的大小。问题是物理没有自动改变以适用于它的新大小,结果是:

在此处输入图像描述

是否有任何简单的方法可以更改对象的大小并且物理特性会自动适应新的大小,或者我必须重写它们?

4

2 回答 2

11

您是否为此目的使用物理编辑器..?

然后scaleFactor提供。您可以使用此比例因子为对象分配物理场,如下所示:

local scaleFactor = 1.0
local physicsData = (require "shapedefs").physicsData(scaleFactor)
local shape = display.newImage("objectname.png")
physics.addBody( shape, physicsData:get("objectname") )

而当你改变 scaleFactor 时,物理区域的大小会自动改变。

更多详情,请访问:http: //vellumininteractive.com/advanced-physics-bodies-with-physics-editor-and-corona-sdk/

于 2013-06-05T08:54:03.993 回答
0

您已将比例更改为 0.5 小,这意味着您必须将所有物理对象更改为 0.5,使用计算器使您的正常数字 / 2 和小于 0 / 2 的数字将它们与结果数字相加,这是一个示例:

24 = 12

-24 = -36

于 2013-06-05T08:41:49.980 回答