电晕物理学不推动身体

Corona Physics not pushing bodies

我正在构建一个俯视图游戏。 我有两个物理体。玩家和房子。我不希望玩家能够走到房子所在的地方。我已经添加了两个身体。

physics.addBody(part.house, "static", {shape=bodies.houses[1]})

physics.addBody(Player, {density=200,radius=30})

房子的形状body做成一个数组

bodies.houses = {
                    {-120, 90, -60, 90, -60, 15, 30, 15, 110, -60, 110, -170, 30, -245, -120, -245},
                    {10, 10, 10, 0, 0, 0, 0, 10},
                    {10, 10, 10, 0, 0, 0, 0, 10}
                }

body 形状本身完美地位于图像上。但是玩家仍然可以 运行 越过房子。请帮忙。

--编辑 1 使用此库移动播放器

local StickLib   = require("lib_analog_stick")

你建筑的形状不是convex as required by the corona docs:

corona docs: Polygonal shapes must be entirely convex. You cannot create shapes with concave bends, for example a bowl or cup. To accomplish such a task, you must assemble the body from multiple polygons, as explained in Multi-Element Bodies below.

convex: In a convex polygon, a line segment between two points on the boundary never goes outside the polygon.

你可以看到它不是凸的,因为黑色线段离开形状但两端都在边界上。您可以将底部矩形位(在绿线下方)断开到另一个主体中以解决此问题。

physics.addBody(part.house, "static",
   {shape={-120, 15, -60, 15, 30, 15, 110, -60, 110, -170, 30, -245, -120, -245}},
   {shape={-120, 90, -60, 90, -60, 15, -120, 15}}
)