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

x33g5p2x  于2022-01-20 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(86)

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

Group.getTouchable介绍

暂无

代码示例

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

public Actor hit (float x, float y, boolean touchable) {
  if (touchable && getTouchable() == Touchable.disabled) return null;
  if (!isVisible()) return null;
  Vector2 point = tmp;
  Actor[] childrenArray = children.items;
  for (int i = children.size - 1; i >= 0; i--) {
    Actor child = childrenArray[i];
    child.parentToLocalCoordinates(point.set(x, y));
    Actor hit = child.hit(point.x, point.y, touchable);
    if (hit != null) return hit;
  }
  return super.hit(x, y, touchable);
}

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

public Actor hit (float x, float y, boolean touchable) {
  if (touchable && getTouchable() == Touchable.disabled) return null;
  if (!isVisible()) return null;
  Vector2 point = tmp;
  Actor[] childrenArray = children.items;
  for (int i = children.size - 1; i >= 0; i--) {
    Actor child = childrenArray[i];
    child.parentToLocalCoordinates(point.set(x, y));
    Actor hit = child.hit(point.x, point.y, touchable);
    if (hit != null) return hit;
  }
  return super.hit(x, y, touchable);
}

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

/** Applies a touch down event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
 * event. */
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
  if (!isInsideViewport(screenX, screenY)) return false;
  pointerTouched[pointer] = true;
  pointerScreenX[pointer] = screenX;
  pointerScreenY[pointer] = screenY;
  screenToStageCoordinates(tempCoords.set(screenX, screenY));
  InputEvent event = Pools.obtain(InputEvent.class);
  event.setType(Type.touchDown);
  event.setStage(this);
  event.setStageX(tempCoords.x);
  event.setStageY(tempCoords.y);
  event.setPointer(pointer);
  event.setButton(button);
  Actor target = hit(tempCoords.x, tempCoords.y, true);
  if (target == null) {
    if (root.getTouchable() == Touchable.enabled) root.fire(event);
  } else
    target.fire(event);
  boolean handled = event.isHandled();
  Pools.free(event);
  return handled;
}

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

/** Applies a touch down event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
 * event. */
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
  if (!isInsideViewport(screenX, screenY)) return false;
  pointerTouched[pointer] = true;
  pointerScreenX[pointer] = screenX;
  pointerScreenY[pointer] = screenY;
  screenToStageCoordinates(tempCoords.set(screenX, screenY));
  InputEvent event = Pools.obtain(InputEvent.class);
  event.setType(Type.touchDown);
  event.setStage(this);
  event.setStageX(tempCoords.x);
  event.setStageY(tempCoords.y);
  event.setPointer(pointer);
  event.setButton(button);
  Actor target = hit(tempCoords.x, tempCoords.y, true);
  if (target == null) {
    if (root.getTouchable() == Touchable.enabled) root.fire(event);
  } else
    target.fire(event);
  boolean handled = event.isHandled();
  Pools.free(event);
  return handled;
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

public Actor hit (float x, float y, boolean touchable) {
  if (touchable && getTouchable() == Touchable.disabled) return null;
  if (!isVisible()) return null;
  Vector2 point = tmp;
  Actor[] childrenArray = children.items;
  for (int i = children.size - 1; i >= 0; i--) {
    Actor child = childrenArray[i];
    child.parentToLocalCoordinates(point.set(x, y));
    Actor hit = child.hit(point.x, point.y, touchable);
    if (hit != null) return hit;
  }
  return super.hit(x, y, touchable);
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** Applies a touch down event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
 * event. */
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
  if (!isInsideViewport(screenX, screenY)) return false;
  pointerTouched[pointer] = true;
  pointerScreenX[pointer] = screenX;
  pointerScreenY[pointer] = screenY;
  screenToStageCoordinates(tempCoords.set(screenX, screenY));
  InputEvent event = Pools.obtain(InputEvent.class);
  event.setType(Type.touchDown);
  event.setStage(this);
  event.setStageX(tempCoords.x);
  event.setStageY(tempCoords.y);
  event.setPointer(pointer);
  event.setButton(button);
  Actor target = hit(tempCoords.x, tempCoords.y, true);
  if (target == null) {
    if (root.getTouchable() == Touchable.enabled) root.fire(event);
  } else
    target.fire(event);
  boolean handled = event.isHandled();
  Pools.free(event);
  return handled;
}

代码示例来源:origin: Var3D/var3dframe

if (getRoot().getTouchable() == Touchable.enabled) {
  back();

相关文章

微信公众号

最新文章

更多