本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.isInsideViewport()
方法的一些代码示例,展示了Stage.isInsideViewport()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.isInsideViewport()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:isInsideViewport
[英]Check if screen coordinates are inside the viewport's screen area.
[中]检查屏幕坐标是否在视口的屏幕区域内。
代码示例来源: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: 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: 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;
}
内容来源于网络,如有侵权,请联系作者删除!