本文整理了Java中com.badlogic.gdx.Graphics.getHeight()
方法的一些代码示例,展示了Graphics.getHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics.getHeight()
方法的具体详情如下:
包路径:com.badlogic.gdx.Graphics
类名称:Graphics
方法名:getHeight
暂无
代码示例来源:origin: libgdx/libgdx
/** Returns the top gutter (black bar) height in screen coordinates. */
public int getTopGutterHeight () {
return Gdx.graphics.getHeight() - (screenY + screenHeight);
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean touchDown (int x, int y, int pointer, int button) {
position.x = x;
position.y = Gdx.graphics.getHeight() - y;
return true;
}
代码示例来源:origin: libgdx/libgdx
/**
* Convers an y-coordinate given in backbuffer coordinates to
* logical screen coordinates
*/
public static int toLogicalY(int backBufferY) {
return (int)(backBufferY * Gdx.graphics.getHeight() / (float)Gdx.graphics.getBackBufferHeight());
}
代码示例来源:origin: libgdx/libgdx
/**
* Convers an y-coordinate given in backbuffer coordinates to
* logical screen coordinates
*/
public static int toBackBufferY(int logicalY) {
return (int)(logicalY * Gdx.graphics.getBackBufferHeight() / (float)Gdx.graphics.getHeight());
}
}
代码示例来源:origin: libgdx/libgdx
/**
* Convers an y-coordinate given in backbuffer coordinates to
* logical screen coordinates
*/
public static int toLogicalY(int backBufferY) {
return (int)(backBufferY * Gdx.graphics.getHeight() / (float)Gdx.graphics.getBackBufferHeight());
}
代码示例来源:origin: libgdx/libgdx
/**
* Convers an y-coordinate given in backbuffer coordinates to
* logical screen coordinates
*/
public static int toBackBufferY(int logicalY) {
return (int)(logicalY * Gdx.graphics.getBackBufferHeight() / (float)Gdx.graphics.getHeight());
}
}
代码示例来源:origin: libgdx/libgdx
/** Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject but does not
* rely on OpenGL. The viewport is assumed to span the whole screen and is fetched from {@link Graphics#getWidth()} and
* {@link Graphics#getHeight()}. The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the top left
* corner, y pointing down, x pointing to the right) as reported by the touch methods in {@link Input}. A z-coordinate of 0
* will return a point on the near plane, a z-coordinate of 1 will return a point on the far plane.
* @param screenCoords the point in screen coordinates
* @return the mutated and unprojected screenCoords {@link Vector3} */
public Vector3 unproject (Vector3 screenCoords) {
unproject(screenCoords, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
return screenCoords;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void resize (int width, int height) {
float ratio = ((float)Gdx.graphics.getWidth() / (float)Gdx.graphics.getHeight());
int h = 10;
int w = (int)(h * ratio);
camera = new OrthographicCamera(w, h);
}
}
代码示例来源:origin: libgdx/libgdx
/** Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at
* (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down.
* @param yDown whether y should be pointing down */
public void setToOrtho (boolean yDown) {
setToOrtho(yDown, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean zoom (float initialDistance, float distance) {
float newZoom = distance - initialDistance;
float amount = newZoom - previousZoom;
previousZoom = newZoom;
float w = Gdx.graphics.getWidth(), h = Gdx.graphics.getHeight();
return controller.pinchZoom(amount / ((w > h) ? h : w));
}
代码示例来源:origin: libgdx/libgdx
/** Calculates a scissor rectangle using 0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight() as the viewport.
* @see #calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle) */
public static void calculateScissors (Camera camera, Matrix4 batchTransform, Rectangle area, Rectangle scissor) {
calculateScissors(camera, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), batchTransform, area, scissor);
}
代码示例来源:origin: libgdx/libgdx
/** Creates a stage with the specified viewport and batch. This can be used to avoid creating a new batch (which can be
* somewhat slow) if multiple stages are used during an application's life time.
* @param batch Will not be disposed if {@link #dispose()} is called, handle disposal yourself. */
public Stage (Viewport viewport, Batch batch) {
if (viewport == null) throw new IllegalArgumentException("viewport cannot be null.");
if (batch == null) throw new IllegalArgumentException("batch cannot be null.");
this.viewport = viewport;
this.batch = batch;
root = new Group();
root.setStage(this);
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
}
代码示例来源:origin: libgdx/libgdx
@Override
public boolean touchDragged (int screenX, int screenY, int pointer) {
boolean result = super.touchDragged(screenX, screenY, pointer);
if (result || this.button < 0) return result;
final float deltaX = (screenX - startX) / Gdx.graphics.getWidth();
final float deltaY = (startY - screenY) / Gdx.graphics.getHeight();
startX = screenX;
startY = screenY;
return process(deltaX, deltaY, button);
}
代码示例来源:origin: libgdx/libgdx
/** Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top
* left and the the y-axis is pointing downwards. */
public Vector2 toScreenCoordinates (Vector2 worldCoords, Matrix4 transformMatrix) {
tmp.set(worldCoords.x, worldCoords.y, 0);
tmp.mul(transformMatrix);
camera.project(tmp);
tmp.y = Gdx.graphics.getHeight() - tmp.y;
worldCoords.x = tmp.x;
worldCoords.y = tmp.y;
return worldCoords;
}
代码示例来源:origin: libgdx/libgdx
/** Transforms a point to real screen coordinates (as opposed to OpenGL ES window coordinates), where the origin is in the top
* left and the the y-axis is pointing downwards. */
public Vector2 toScreenCoordinates (Vector2 worldCoords, Matrix4 transformMatrix) {
tmp.set(worldCoords.x, worldCoords.y, 0);
tmp.mul(transformMatrix);
camera.project(tmp);
tmp.y = Gdx.graphics.getHeight() - tmp.y;
worldCoords.x = tmp.x;
worldCoords.y = tmp.y;
return worldCoords;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
font.draw(batch, message, 20, Gdx.graphics.getHeight() - 20);
batch.end();
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
font.draw(batch, message, 20, Gdx.graphics.getHeight() - 20);
batch.end();
}
代码示例来源:origin: libgdx/libgdx
public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) {
if (defaultShader == null) {
renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0);
} else {
renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader);
}
projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
matrixDirty = true;
}
代码示例来源:origin: libgdx/libgdx
public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) {
if (defaultShader == null) {
renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0);
} else {
renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader);
}
projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
matrixDirty = true;
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(texture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.end();
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
int color = pixmap.getPixel(0, pixmap.getHeight() - 1);
Gdx.app.log("AlphaTest", Integer.toHexString(color));
pixmap.dispose();
}
内容来源于网络,如有侵权,请联系作者删除!