本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.hit()
方法的一些代码示例,展示了Stage.hit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.hit()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:hit
[英]Returns the Actor at the specified location in stage coordinates. Hit testing is performed in the order the actors were inserted into the stage, last inserted actors being tested first. To get stage coordinates from screen coordinates, use #screenToStageCoordinates(Vector2).
[中]返回舞台坐标中指定位置的演员。命中测试按照演员被插入舞台的顺序进行,最后一个插入的演员首先被测试。要从屏幕坐标中获取舞台坐标,请使用#屏幕到舞台坐标(矢量2)。
代码示例来源:origin: libgdx/libgdx
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
* event. This event only occurs on the desktop. */
public boolean mouseMoved (int screenX, int screenY) {
mouseScreenX = screenX;
mouseScreenY = screenY;
if (!isInsideViewport(screenX, screenY)) return false;
screenToStageCoordinates(tempCoords.set(screenX, screenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(Type.mouseMoved);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
Actor target = hit(tempCoords.x, tempCoords.y, true);
if (target == null) target = root;
target.fire(event);
boolean handled = event.isHandled();
Pools.free(event);
return handled;
}
代码示例来源:origin: libgdx/libgdx
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
* event. This event only occurs on the desktop. */
public boolean mouseMoved (int screenX, int screenY) {
mouseScreenX = screenX;
mouseScreenY = screenY;
if (!isInsideViewport(screenX, screenY)) return false;
screenToStageCoordinates(tempCoords.set(screenX, screenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(Type.mouseMoved);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
Actor target = hit(tempCoords.x, tempCoords.y, true);
if (target == null) target = root;
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: 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
Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);
if (actor != null)
actor.setColor((float)Math.random(), (float)Math.random(), (float)Math.random(), 0.5f + 0.5f * (float)Math.random());
代码示例来源:origin: libgdx/libgdx
isValidTarget = false;
float stageX = event.getStageX() + touchOffsetX, stageY = event.getStageY() + touchOffsetY;
Actor hit = event.getStage().hit(stageX, stageY, true); // Prefer touchable actors.
if (hit == null) hit = event.getStage().hit(stageX, stageY, false);
if (hit != null) {
for (int i = 0, n = targets.size; i < n; i++) {
代码示例来源:origin: libgdx/libgdx
isValidTarget = false;
float stageX = event.getStageX() + touchOffsetX, stageY = event.getStageY() + touchOffsetY;
Actor hit = event.getStage().hit(stageX, stageY, true); // Prefer touchable actors.
if (hit == null) hit = event.getStage().hit(stageX, stageY, false);
if (hit != null) {
for (int i = 0, n = targets.size; i < n; i++) {
代码示例来源:origin: libgdx/libgdx
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: libgdx/libgdx
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: libgdx/libgdx
private Actor fireEnterAndExit (Actor overLast, int screenX, int screenY, int pointer) {
Actor over = hit(tempCoords.x, tempCoords.y, true);
if (over == overLast) return overLast;
代码示例来源:origin: libgdx/libgdx
private Actor fireEnterAndExit (Actor overLast, int screenX, int screenY, int pointer) {
Actor over = hit(tempCoords.x, tempCoords.y, true);
if (over == overLast) return overLast;
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
* event. This event only occurs on the desktop. */
public boolean mouseMoved (int screenX, int screenY) {
mouseScreenX = screenX;
mouseScreenY = screenY;
if (!isInsideViewport(screenX, screenY)) return false;
screenToStageCoordinates(tempCoords.set(screenX, screenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(Type.mouseMoved);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
Actor target = hit(tempCoords.x, tempCoords.y, true);
if (target == null) target = root;
target.fire(event);
boolean handled = event.isHandled();
Pools.free(event);
return handled;
}
代码示例来源:origin: kotcrab/vis-ui
@Override
public boolean onEnd (final Draggable draggable, final Actor actor, final float stageX, final float stageY) {
if (actor == null || actor.getStage() == null) {
return CANCEL;
}
final Actor overActor = actor.getStage().hit(stageX, stageY, true);
if (overActor == null || overActor == actor) {
return CANCEL;
} else if (overActor.isAscendantOf(actor)) {
final DragPane dragPane = getDragPane(actor);
if (dragPane != null && dragPane.isFloating()) {
DRAG_POSITION.set(stageX, stageY);
return addToFloatingGroup(draggable, actor, dragPane);
}
return CANCEL;
}
DRAG_POSITION.set(stageX, stageY);
if (overActor instanceof DragPane) {
return addDirectlyToPane(draggable, actor, (DragPane) overActor);
}
final DragPane dragPane = getDragPane(overActor);
if (accept(actor, dragPane)) {
return addActor(draggable, actor, overActor, dragPane);
}
return CANCEL;
}
代码示例来源: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: com.badlogicgames.gdx/gdx
isValidTarget = false;
float stageX = event.getStageX() + touchOffsetX, stageY = event.getStageY() + touchOffsetY;
Actor hit = event.getStage().hit(stageX, stageY, true); // Prefer touchable actors.
if (hit == null) hit = event.getStage().hit(stageX, stageY, false);
if (hit != null) {
for (int i = 0, n = targets.size; i < n; i++) {
代码示例来源:origin: com.badlogicgames.gdx/gdx
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
Actor hit = stage.hit(tmpVec2.x, tmpVec2.y, true);
boolean include = hit == btnInclude;
boolean exclude = hit == btnExclude;
代码示例来源:origin: com.badlogicgames.gdx/gdx
private Actor fireEnterAndExit (Actor overLast, int screenX, int screenY, int pointer) {
Actor over = hit(tempCoords.x, tempCoords.y, true);
if (over == overLast) return overLast;
内容来源于网络,如有侵权,请联系作者删除!