コード例 #1
0
 /**
  * Apply force on joint, pushing the attached entity out of place.
  *
  * @param attached Attached component of entity to push
  * @param rotation Direction of force
  * @param force strength of force (don't factor in delta).
  */
 public void push(final Attached attached, float rotation, float force) {
   vTmp.set(force, 0)
       .rotate(rotation)
       .add(attached.slackX, attached.slackY)
       .clamp(0f, attached.maxSlack);
   attached.slackX = vTmp.x;
   attached.slackY = vTmp.y;
 }
コード例 #2
0
  /**
   * Slack, like weapon recoil on the joint.
   *
   * @param attached
   */
  protected void updateSlack(final Attached attached) {

    float len = vTmp.set(attached.slackX, attached.slackY).len() - world.delta * attached.tension;
    if (len > 0) {
      vTmp.nor().scl(len);
    } else {
      vTmp.set(0, 0);
    }

    attached.slackX = vTmp.x;
    attached.slackY = vTmp.y;
  }