com.badlogic.gdx.scenes.scene2d.Actor.stageToLocalCoordinates()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.stageToLocalCoordinates()方法的一些代码示例,展示了Actor.stageToLocalCoordinates()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.stageToLocalCoordinates()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:stageToLocalCoordinates

Actor.stageToLocalCoordinates介绍

[英]Transforms the specified point in the stage's coordinates to the actor's local coordinate system.
[中]将舞台坐标中的指定点转换为演员的局部坐标系。

代码示例

代码示例来源:origin: libgdx/libgdx

/** Transforms the specified point in screen coordinates to the actor's local coordinate system.
 * @see Stage#screenToStageCoordinates(Vector2) */
public Vector2 screenToLocalCoordinates (Vector2 screenCoords) {
  Stage stage = this.stage;
  if (stage == null) return screenCoords;
  return stageToLocalCoordinates(stage.screenToStageCoordinates(screenCoords));
}

代码示例来源:origin: libgdx/libgdx

/** Converts coordinates for this actor to those of another actor, which can be anywhere in the stage. */
public Vector2 localToActorCoordinates (Actor actor, Vector2 localCoords) {
  localToStageCoordinates(localCoords);
  return actor.stageToLocalCoordinates(localCoords);
}

代码示例来源:origin: libgdx/libgdx

private void stageToLocalAmount (Vector2 amount) {
    actor.stageToLocalCoordinates(amount);
    amount.sub(actor.stageToLocalCoordinates(tmpCoords2.set(0, 0)));
  }
});

代码示例来源:origin: libgdx/libgdx

/** Converts coordinates for this actor to those of another actor, which can be anywhere in the stage. */
public Vector2 localToActorCoordinates (Actor actor, Vector2 localCoords) {
  localToStageCoordinates(localCoords);
  return actor.stageToLocalCoordinates(localCoords);
}

代码示例来源:origin: libgdx/libgdx

private void stageToLocalAmount (Vector2 amount) {
    actor.stageToLocalCoordinates(amount);
    amount.sub(actor.stageToLocalCoordinates(tmpCoords2.set(0, 0)));
  }
});

代码示例来源:origin: libgdx/libgdx

/** Transforms the specified point in screen coordinates to the actor's local coordinate system.
 * @see Stage#screenToStageCoordinates(Vector2) */
public Vector2 screenToLocalCoordinates (Vector2 screenCoords) {
  Stage stage = this.stage;
  if (stage == null) return screenCoords;
  return stageToLocalCoordinates(stage.screenToStageCoordinates(screenCoords));
}

代码示例来源:origin: libgdx/libgdx

/** Sets actorCoords to this event's coordinates relative to the specified actor.
 * @param actorCoords Output for resulting coordinates. */
public Vector2 toCoordinates (Actor actor, Vector2 actorCoords) {
  actorCoords.set(stageX, stageY);
  actor.stageToLocalCoordinates(actorCoords);
  return actorCoords;
}

代码示例来源:origin: libgdx/libgdx

/** Sets actorCoords to this event's coordinates relative to the specified actor.
 * @param actorCoords Output for resulting coordinates. */
public Vector2 toCoordinates (Actor actor, Vector2 actorCoords) {
  actorCoords.set(stageX, stageY);
  actor.stageToLocalCoordinates(actorCoords);
  return actorCoords;
}

代码示例来源:origin: libgdx/libgdx

public boolean pinch (Vector2 stageInitialPointer1, Vector2 stageInitialPointer2, Vector2 stagePointer1,
  Vector2 stagePointer2) {
  actor.stageToLocalCoordinates(initialPointer1.set(stageInitialPointer1));
  actor.stageToLocalCoordinates(initialPointer2.set(stageInitialPointer2));
  actor.stageToLocalCoordinates(pointer1.set(stagePointer1));
  actor.stageToLocalCoordinates(pointer2.set(stagePointer2));
  ActorGestureListener.this.pinch(event, initialPointer1, initialPointer2, pointer1, pointer2);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public boolean pinch (Vector2 stageInitialPointer1, Vector2 stageInitialPointer2, Vector2 stagePointer1,
  Vector2 stagePointer2) {
  actor.stageToLocalCoordinates(initialPointer1.set(stageInitialPointer1));
  actor.stageToLocalCoordinates(initialPointer2.set(stageInitialPointer2));
  actor.stageToLocalCoordinates(pointer1.set(stagePointer1));
  actor.stageToLocalCoordinates(pointer2.set(stagePointer2));
  ActorGestureListener.this.pinch(event, initialPointer1, initialPointer2, pointer1, pointer2);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public boolean tap (float stageX, float stageY, int count, int button) {
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  ActorGestureListener.this.tap(event, tmpCoords.x, tmpCoords.y, count, button);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public boolean longPress (float stageX, float stageY) {
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  return ActorGestureListener.this.longPress(actor, tmpCoords.x, tmpCoords.y);
}

代码示例来源:origin: libgdx/libgdx

public boolean tap (float stageX, float stageY, int count, int button) {
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  ActorGestureListener.this.tap(event, tmpCoords.x, tmpCoords.y, count, button);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public boolean longPress (float stageX, float stageY) {
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  return ActorGestureListener.this.longPress(actor, tmpCoords.x, tmpCoords.y);
}

代码示例来源:origin: libgdx/libgdx

public boolean pan (float stageX, float stageY, float deltaX, float deltaY) {
  stageToLocalAmount(tmpCoords.set(deltaX, deltaY));
  deltaX = tmpCoords.x;
  deltaY = tmpCoords.y;
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  ActorGestureListener.this.pan(event, tmpCoords.x, tmpCoords.y, deltaX, deltaY);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public boolean pan (float stageX, float stageY, float deltaX, float deltaY) {
  stageToLocalAmount(tmpCoords.set(deltaX, deltaY));
  deltaX = tmpCoords.x;
  deltaY = tmpCoords.y;
  actor.stageToLocalCoordinates(tmpCoords.set(stageX, stageY));
  ActorGestureListener.this.pan(event, tmpCoords.x, tmpCoords.y, deltaX, deltaY);
  return true;
}

代码示例来源:origin: libgdx/libgdx

public void dragStop (InputEvent event, float x, float y, int pointer) {
    if (pointer != activePointer) return;
    activePointer = -1;
    if (payload == null) return;
    if (System.currentTimeMillis() - dragStartTime < dragTime) isValidTarget = false;
    if (dragActor != null) dragActor.remove();
    if (isValidTarget) {
      float stageX = event.getStageX() + touchOffsetX, stageY = event.getStageY() + touchOffsetY;
      target.actor.stageToLocalCoordinates(tmpVector.set(stageX, stageY));
      target.drop(source, payload, tmpVector.x, tmpVector.y, pointer);
    }
    source.dragStop(event, x, y, pointer, payload, isValidTarget ? target : null);
    if (target != null) target.reset(source, payload);
    dragSource = null;
    payload = null;
    target = null;
    isValidTarget = false;
    dragActor = null;
  }
};

代码示例来源:origin: libgdx/libgdx

public void dragStop (InputEvent event, float x, float y, int pointer) {
    if (pointer != activePointer) return;
    activePointer = -1;
    if (payload == null) return;
    if (System.currentTimeMillis() - dragStartTime < dragTime) isValidTarget = false;
    if (dragActor != null) dragActor.remove();
    if (isValidTarget) {
      float stageX = event.getStageX() + touchOffsetX, stageY = event.getStageY() + touchOffsetY;
      target.actor.stageToLocalCoordinates(tmpVector.set(stageX, stageY));
      target.drop(source, payload, tmpVector.x, tmpVector.y, pointer);
    }
    source.dragStop(event, x, y, pointer, payload, isValidTarget ? target : null);
    if (target != null) target.reset(source, payload);
    dragSource = null;
    payload = null;
    target = null;
    isValidTarget = false;
    dragActor = null;
  }
};

代码示例来源:origin: libgdx/libgdx

public boolean handle (Event e) {
  if (!(e instanceof InputEvent)) return false;
  InputEvent event = (InputEvent)e;
  switch (event.getType()) {
  case touchDown:
    actor = event.getListenerActor();
    touchDownTarget = event.getTarget();
    detector.touchDown(event.getStageX(), event.getStageY(), event.getPointer(), event.getButton());
    actor.stageToLocalCoordinates(tmpCoords.set(event.getStageX(), event.getStageY()));
    touchDown(event, tmpCoords.x, tmpCoords.y, event.getPointer(), event.getButton());
    return true;
  case touchUp:
    if (event.isTouchFocusCancel()) {
      detector.reset();
      return false;
    }
    this.event = event;
    actor = event.getListenerActor();
    detector.touchUp(event.getStageX(), event.getStageY(), event.getPointer(), event.getButton());
    actor.stageToLocalCoordinates(tmpCoords.set(event.getStageX(), event.getStageY()));
    touchUp(event, tmpCoords.x, tmpCoords.y, event.getPointer(), event.getButton());
    return true;
  case touchDragged:
    this.event = event;
    actor = event.getListenerActor();
    detector.touchDragged(event.getStageX(), event.getStageY(), event.getPointer());
    return true;
  }
  return false;
}

代码示例来源:origin: libgdx/libgdx

public boolean handle (Event e) {
  if (!(e instanceof InputEvent)) return false;
  InputEvent event = (InputEvent)e;
  switch (event.getType()) {
  case touchDown:
    actor = event.getListenerActor();
    touchDownTarget = event.getTarget();
    detector.touchDown(event.getStageX(), event.getStageY(), event.getPointer(), event.getButton());
    actor.stageToLocalCoordinates(tmpCoords.set(event.getStageX(), event.getStageY()));
    touchDown(event, tmpCoords.x, tmpCoords.y, event.getPointer(), event.getButton());
    return true;
  case touchUp:
    if (event.isTouchFocusCancel()) {
      detector.reset();
      return false;
    }
    this.event = event;
    actor = event.getListenerActor();
    detector.touchUp(event.getStageX(), event.getStageY(), event.getPointer(), event.getButton());
    actor.stageToLocalCoordinates(tmpCoords.set(event.getStageX(), event.getStageY()));
    touchUp(event, tmpCoords.x, tmpCoords.y, event.getPointer(), event.getButton());
    return true;
  case touchDragged:
    this.event = event;
    actor = event.getListenerActor();
    detector.touchDragged(event.getStageX(), event.getStageY(), event.getPointer());
    return true;
  }
  return false;
}

相关文章