小编Des*_*121的帖子

如何将对象从节点移动到节点?Libgdx Box2d A*寻路

我无法成功地让敌人从一个节点移动到另一个节点。

我设法设置了整个寻路,我得到了玩家的完整路径和下一个节点的位置,一直到最后。

如何将 box2d 主体从一个节点移动到另一个节点?

或者更简单 - 如何将 box2d 主体移动到某个位置?我尝试施加冲动,力量无法做到。

这是我的简化代码。Monster 和 Player 类都扩展了 Sprite:

public class B2dSteeringEntity implements Steerable<Vector2>, Updateable {

public static final String TAG = B2dSteeringEntity.class.getName();

    Body body;
    boolean tagged;
    float maxLinearSpeed, maxLinearAcceleration;
    float maxAngularSpeed, maxAngularAcceleration;
    float boundingRadius;

SteeringBehavior<Vector2> behavior;
SteeringAcceleration<Vector2> steeringOutput;

public B2dSteeringEntity(Body body, float boundingRadius) {
    this.body = body;
    this.boundingRadius = boundingRadius;

    this.maxLinearSpeed = 250;
    this.maxLinearAcceleration = 200;
    this.maxAngularSpeed = 0;
    this.maxAngularAcceleration = 0;

    this.tagged = false;

    this.steeringOutput = new SteeringAcceleration<Vector2>(new Vector2());
}

@Override
public …
Run Code Online (Sandbox Code Playgroud)

java path-finding box2d libgdx

6
推荐指数
1
解决办法
199
查看次数

标签 统计

box2d ×1

java ×1

libgdx ×1

path-finding ×1