本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.screenToStageCoordinates()
方法的一些代码示例,展示了Stage.screenToStageCoordinates()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.screenToStageCoordinates()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:screenToStageCoordinates
[英]Transforms the screen coordinates to stage coordinates.
[中]将屏幕坐标转换为舞台坐标。
代码示例来源: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
/** 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
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
if (!Float.isNaN(time)) // if "walking" was interrupted by this touch down event
startPosition.set(getPosition(time)); // set startPosition to the current position
targetPosition.set(stage.screenToStageCoordinates(targetPosition.set(screenX, screenY)));
time = 0;
return true;
}
代码示例来源:origin: libgdx/libgdx
/** Applies a mouse scroll 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 scrolled (int amount) {
Actor target = scrollFocus == null ? root : scrollFocus;
screenToStageCoordinates(tempCoords.set(mouseScreenX, mouseScreenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(InputEvent.Type.scrolled);
event.setScrollAmount(amount);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
target.fire(event);
boolean handled = event.isHandled();
Pools.free(event);
return handled;
}
代码示例来源:origin: libgdx/libgdx
/** Applies a mouse scroll 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 scrolled (int amount) {
Actor target = scrollFocus == null ? root : scrollFocus;
screenToStageCoordinates(tempCoords.set(mouseScreenX, mouseScreenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(InputEvent.Type.scrolled);
event.setScrollAmount(amount);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
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 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
if (overLast != null) {
pointerOverActors[pointer] = null;
screenToStageCoordinates(tempCoords.set(pointerScreenX[pointer], pointerScreenY[pointer]));
代码示例来源:origin: libgdx/libgdx
stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY()));
Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);
if (actor != null)
代码示例来源:origin: libgdx/libgdx
if (overLast != null) {
pointerOverActors[pointer] = null;
screenToStageCoordinates(tempCoords.set(pointerScreenX[pointer], pointerScreenY[pointer]));
代码示例来源:origin: libgdx/libgdx
/** Applies a touch moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
* event. Only {@link InputListener listeners} that returned true for touchDown will receive this event. */
public boolean touchDragged (int screenX, int screenY, int pointer) {
pointerScreenX[pointer] = screenX;
pointerScreenY[pointer] = screenY;
mouseScreenX = screenX;
mouseScreenY = screenY;
if (touchFocuses.size == 0) return false;
screenToStageCoordinates(tempCoords.set(screenX, screenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setType(Type.touchDragged);
event.setStage(this);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
event.setPointer(pointer);
SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses;
TouchFocus[] focuses = touchFocuses.begin();
for (int i = 0, n = touchFocuses.size; i < n; i++) {
TouchFocus focus = focuses[i];
if (focus.pointer != pointer) continue;
if (!touchFocuses.contains(focus, true)) continue; // Touch focus already gone.
event.setTarget(focus.target);
event.setListenerActor(focus.listenerActor);
if (focus.listener.handle(event)) event.handle();
}
touchFocuses.end();
boolean handled = event.isHandled();
Pools.free(event);
return handled;
}
代码示例来源:origin: libgdx/libgdx
/** Applies a touch moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the
* event. Only {@link InputListener listeners} that returned true for touchDown will receive this event. */
public boolean touchDragged (int screenX, int screenY, int pointer) {
pointerScreenX[pointer] = screenX;
pointerScreenY[pointer] = screenY;
mouseScreenX = screenX;
mouseScreenY = screenY;
if (touchFocuses.size == 0) return false;
screenToStageCoordinates(tempCoords.set(screenX, screenY));
InputEvent event = Pools.obtain(InputEvent.class);
event.setType(Type.touchDragged);
event.setStage(this);
event.setStageX(tempCoords.x);
event.setStageY(tempCoords.y);
event.setPointer(pointer);
SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses;
TouchFocus[] focuses = touchFocuses.begin();
for (int i = 0, n = touchFocuses.size; i < n; i++) {
TouchFocus focus = focuses[i];
if (focus.pointer != pointer) continue;
if (!touchFocuses.contains(focus, true)) continue; // Touch focus already gone.
event.setTarget(focus.target);
event.setListenerActor(focus.listenerActor);
if (focus.listener.handle(event)) event.handle();
}
touchFocuses.end();
boolean handled = event.isHandled();
Pools.free(event);
return handled;
}
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
Actor actor = hit(tempCoords.x, tempCoords.y, true);
if (actor == null) return;
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(screenX, screenY));
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(screenX, screenY));
代码示例来源:origin: libgdx/libgdx
screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
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) {
screenToStageCoordinates(tempCoords.set(screenX, screenY));
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) {
screenToStageCoordinates(tempCoords.set(screenX, screenY));
Actor over = hit(tempCoords.x, tempCoords.y, true);
if (over == overLast) return overLast;
内容来源于网络,如有侵权,请联系作者删除!