Esempio n. 1
0
  // can be performed in update
  public void maybeTeleport(SolGame game, SolShip owner) {
    if (!myShouldTeleport) return;

    TextureAtlas.AtlasRegion tex = game.getTexMan().getTex(TEX_PATH, null);
    float blipSz = owner.getHull().config.getApproxRadius() * 3;
    game.getPartMan().blip(game, owner.getPos(), SolMath.rnd(180), blipSz, 1, Vector2.Zero, tex);
    game.getPartMan().blip(game, myNewPos, SolMath.rnd(180), blipSz, 1, Vector2.Zero, tex);

    float newAngle = owner.getAngle() + myAngle;
    Vector2 newSpd = SolMath.getVec(owner.getSpd());
    SolMath.rotate(newSpd, myAngle);

    Body body = owner.getHull().getBody();
    body.setTransform(myNewPos, newAngle * SolMath.degRad);
    body.setLinearVelocity(newSpd);

    SolMath.free(newSpd);
  }