libgdx - 是否可以为可能被其他物体破坏的物体创建固定装置?

标签 libgdx box2d fixtures

我真的很想知道,是否有可能为一个可能被其他 body 打破的 body 创造一个固定装置?

有一个例子:

  • 一个 body 及其固定装置分成小数字:
  • 以及被另一具尸体击中后会发生什么:

  • 附言是否有任何程序可以帮助创建此类夹具的过程?

    最佳答案

    是的,您可以使用 Breakable 执行此操作发现于:
    net.dermetfan.gdx.physics.box2d.Breakable
    Breakable 允许轻松地使整个 body 或单个固定装置可破坏,这意味着如果对它们施加一定的力或摩擦力,它们将被破坏。

    使用方法

    A Breakable is meant to be put in a body's, fixture's or joint's user data. A single Breakable instance can be put in the user data of multiple bodies, fixtures and joints. Since this may collide with the Box2DSprite or other classes using the user data, the Breakable$Manager uses a Function to access the Breakable in the user data of a body, fixture or joint.Do not forget to set a Manager instance as ContactListener to the world and to call destroy() after every timestep. If the field is already in use, check out the ContactMultiplexer. The Manager does the actual work, the Breakables are just passive data holders.

    A Breakable consists of a normal resistance, tangent resistance, an option to destroy its body in case its last fixture was destroyed and an option setting if the body should be destroyed no matter the amount of remaining fixtures.

    The normalResistance is the force that can be applied to the Breakable before it breaks (inclusive). The tangentResistance is the friction the Breakable can bear (also inclusive). The reactionForceRestiance specifies the reaction force a joint can bear on each axis. The reactionForceLength2Resistance is the max squared length of the joint's reaction force the Breakable can bear.



    提及libgdx-utils

    其他一些很好的引用和很好的例子 herehere

    for the question (Are there any programs that could help the process of creating such fixture)



    是的,您可以轻松使用 box2d-editor 它允许您创建复杂的多边形,您还可以从您的图像或 Sprite 创建您的 body 和形状 检查同一页面中的官方文档 有几个视频解释了 box2d-editor 的工作方式:

    特征:

    • Automatically decomposes concave shapes into convex polygons,
    • Automatically traces your images if needed,
    • Supports multiple outlines for a single body,
    • Supports polygon and circle shapes,
    • Reference point location can be changed,
    • Visual configurable grid with snap-to-grid option,
    • Built-in collision tester! Throw balls at your body to test it,
    • Loader provided for LibGDX game framework (written in Java),
    • Simple export format (JSON), to let you easily create your own loader for any framework in any language.

    关于libgdx - 是否可以为可能被其他物体破坏的物体创建固定装置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28622291/

    相关文章:

    ruby-on-rails - 如何通过关联(具有中介模型的值)为多对多设置固定装置?

    java - 如何让一个角色走主角路线? LIBGDX/Java

    java - ShapeRenderer 转换干扰 LibGDX 中的网格转换

    java - Libgdx |场景2d |点击隐形按钮时 touchDown 输入处理器方法不会触发

    c++ - Box2D 无法设置密度

    android - 快速移动的物体有时会错过 Box2d 和 AndEngine 中的碰撞

    python - 使用应用程序工厂时在 pytest 测试中访问 Flask 测试客户端 session

    grails - 如何在Grails中创建动态灯具?

    android - libgdx - 触摸和拖动不起作用(滞后并显示在 2 个地方)

    java - (Java LibGDX) 如何在 LibGDX 中调整纹理大小?