- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.Window.getWidth()
方法的一些代码示例,展示了Window.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getWidth()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.Window
类名称:Window
方法名:getWidth
暂无
代码示例来源:origin: libgdx/libgdx
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
if (button == 0) {
updateEdge(x, y);
dragging = edge != 0;
startX = x;
startY = y;
lastX = x - getWidth();
lastY = y - getHeight();
}
return edge != 0 || isModal;
}
代码示例来源:origin: libgdx/libgdx
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
if (button == 0) {
updateEdge(x, y);
dragging = edge != 0;
startX = x;
startY = y;
lastX = x - getWidth();
lastY = y - getHeight();
}
return edge != 0 || isModal;
}
代码示例来源:origin: libgdx/libgdx
private void updateEdge (float x, float y) {
float border = resizeBorder / 2f;
float width = getWidth(), height = getHeight();
float padTop = getPadTop(), padLeft = getPadLeft(), padBottom = getPadBottom(), padRight = getPadRight();
float left = padLeft, right = width - padRight, bottom = padBottom;
edge = 0;
if (isResizable && x >= left - border && x <= right + border && y >= bottom - border) {
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
if (edge != 0) border += 25;
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
}
if (isMovable && edge == 0 && y <= height && y >= height - padTop && x >= left && x <= right) edge = MOVE;
}
代码示例来源:origin: libgdx/libgdx
private void updateEdge (float x, float y) {
float border = resizeBorder / 2f;
float width = getWidth(), height = getHeight();
float padTop = getPadTop(), padLeft = getPadLeft(), padBottom = getPadBottom(), padRight = getPadRight();
float left = padLeft, right = width - padRight, bottom = padBottom;
edge = 0;
if (isResizable && x >= left - border && x <= right + border && y >= bottom - border) {
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
if (edge != 0) border += 25;
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
}
if (isMovable && edge == 0 && y <= height && y >= height - padTop && x >= left && x <= right) edge = MOVE;
}
代码示例来源:origin: libgdx/libgdx
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
super.drawBackground(batch, parentAlpha, x, y);
// Manually draw the title table before clipping is done.
titleTable.getColor().a = getColor().a;
float padTop = getPadTop(), padLeft = getPadLeft();
titleTable.setSize(getWidth() - padLeft - getPadRight(), padTop);
titleTable.setPosition(padLeft, getHeight() - padTop);
drawTitleTable = true;
titleTable.draw(batch, parentAlpha);
drawTitleTable = false; // Avoid drawing the title table again in drawChildren.
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (!isVisible()) return null;
Actor hit = super.hit(x, y, touchable);
if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this;
float height = getHeight();
if (hit == null || hit == this) return hit;
if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) {
// Hit the title bar, don't use the hit child if it is in the Window's table.
Actor current = hit;
while (current.getParent() != this)
current = current.getParent();
if (getCell(current) != null) return this;
}
return hit;
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (!isVisible()) return null;
Actor hit = super.hit(x, y, touchable);
if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this;
float height = getHeight();
if (hit == null || hit == this) return hit;
if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) {
// Hit the title bar, don't use the hit child if it is in the Window's table.
Actor current = hit;
while (current.getParent() != this)
current = current.getParent();
if (getCell(current) != null) return this;
}
return hit;
}
代码示例来源:origin: libgdx/libgdx
public void touchDragged (InputEvent event, float x, float y, int pointer) {
if (!dragging) return;
float width = getWidth(), height = getHeight();
float windowX = getX(), windowY = getY();
代码示例来源:origin: libgdx/libgdx
public void touchDragged (InputEvent event, float x, float y, int pointer) {
if (!dragging) return;
float width = getWidth(), height = getHeight();
float windowX = getX(), windowY = getY();
代码示例来源:origin: libgdx/libgdx
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
super.drawBackground(batch, parentAlpha, x, y);
// Manually draw the title table before clipping is done.
titleTable.getColor().a = getColor().a;
float padTop = getPadTop(), padLeft = getPadLeft();
titleTable.setSize(getWidth() - padLeft - getPadRight(), padTop);
titleTable.setPosition(padLeft, getHeight() - padTop);
drawTitleTable = true;
titleTable.draw(batch, parentAlpha);
drawTitleTable = false; // Avoid drawing the title table again in drawChildren.
}
代码示例来源:origin: libgdx/libgdx
public void keepWithinStage () {
if (!keepWithinStage) return;
Stage stage = getStage();
if (stage == null) return;
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera)camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, getY(Align.right), Align.right);
if (getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, getY(Align.left), Align.left);
if (getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX() < 0) setX(0);
if (getRight() > parentWidth) setX(parentWidth - getWidth());
if (getY() < 0) setY(0);
if (getTop() > parentHeight) setY(parentHeight - getHeight());
}
}
代码示例来源:origin: libgdx/libgdx
public void keepWithinStage () {
if (!keepWithinStage) return;
Stage stage = getStage();
if (stage == null) return;
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera)camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, getY(Align.right), Align.right);
if (getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, getY(Align.left), Align.left);
if (getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX() < 0) setX(0);
if (getRight() > parentWidth) setX(parentWidth - getWidth());
if (getY() < 0) setY(0);
if (getTop() > parentHeight) setY(parentHeight - getHeight());
}
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
if (button == 0) {
updateEdge(x, y);
dragging = edge != 0;
startX = x;
startY = y;
lastX = x - getWidth();
lastY = y - getHeight();
}
return edge != 0 || isModal;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
private void updateEdge (float x, float y) {
float border = resizeBorder / 2f;
float width = getWidth(), height = getHeight();
float padTop = getPadTop(), padLeft = getPadLeft(), padBottom = getPadBottom(), padRight = getPadRight();
float left = padLeft, right = width - padRight, bottom = padBottom;
edge = 0;
if (isResizable && x >= left - border && x <= right + border && y >= bottom - border) {
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
if (edge != 0) border += 25;
if (x < left + border) edge |= Align.left;
if (x > right - border) edge |= Align.right;
if (y < bottom + border) edge |= Align.bottom;
}
if (isMovable && edge == 0 && y <= height && y >= height - padTop && x >= left && x <= right) edge = MOVE;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public Actor hit (float x, float y, boolean touchable) {
if (!isVisible()) return null;
Actor hit = super.hit(x, y, touchable);
if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this;
float height = getHeight();
if (hit == null || hit == this) return hit;
if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) {
// Hit the title bar, don't use the hit child if it is in the Window's table.
Actor current = hit;
while (current.getParent() != this)
current = current.getParent();
if (getCell(current) != null) return this;
}
return hit;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void touchDragged (InputEvent event, float x, float y, int pointer) {
if (!dragging) return;
float width = getWidth(), height = getHeight();
float windowX = getX(), windowY = getY();
代码示例来源:origin: com.badlogicgames.gdx/gdx
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
super.drawBackground(batch, parentAlpha, x, y);
// Manually draw the title table before clipping is done.
titleTable.getColor().a = getColor().a;
float padTop = getPadTop(), padLeft = getPadLeft();
titleTable.setSize(getWidth() - padLeft - getPadRight(), padTop);
titleTable.setPosition(padLeft, getHeight() - padTop);
drawTitleTable = true;
titleTable.draw(batch, parentAlpha);
drawTitleTable = false; // Avoid drawing the title table again in drawChildren.
}
代码示例来源:origin: narfman0/GDXWorld
window.row();
window.pack();
window.setX(Gdx.graphics.getWidth()/2 - window.getWidth()/2);
window.setY(Gdx.graphics.getHeight()/2 - window.getHeight()/2);
stage.addActor(window);
代码示例来源:origin: narfman0/GDXWorld
window.add(exitButton).colspan(2);
window.pack();
window.setX(Gdx.graphics.getWidth()/2 - window.getWidth()/2);
window.setY(Gdx.graphics.getHeight()/2 - window.getHeight()/2);
stage.addActor(window);
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void keepWithinStage () {
if (!keepWithinStage) return;
Stage stage = getStage();
if (stage == null) return;
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera)camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, getY(Align.right), Align.right);
if (getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, getY(Align.left), Align.left);
if (getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX() < 0) setX(0);
if (getRight() > parentWidth) setX(parentWidth - getWidth());
if (getY() < 0) setY(0);
if (getTop() > parentHeight) setY(parentHeight - getHeight());
}
}
我有一个游戏编辑器,可以在单独的窗口(但在同一个 VM 中)中启动正在编辑的游戏。但是,当游戏关闭时,我想关闭它的 gdx 窗口,而不关闭整个应用程序(即编辑器)。 我目前在托管 LwjglAppli
我正在尝试在我的 libgdx 项目中实现 gdx-pay。所以我跟着Integration example with resolvers来自 libgdx wiki。 我在我的核心项目中创建了一个类
我在游戏中使用 libgdx。我想读/写文本文件来更新高分,非常简单。我已经在“$ANDROID-PROJECT/assets/data”中创建了三个文件,但是当我使用 Gdx.files.local
我正在使用 libgdx 框架,我不确定访问 opengl API 的首选方式是什么,我的应用程序使用 OpenGl 2.0(useGL20 标志设置为 true)。现在清除例如我可以做的屏幕: Gd
我使用 gdx-setup.jar 生成了一个 gradle 项目,然后将它导入到 Android Studio 中。但是当我尝试编译它时,我得到了这个错误。 我在生成和使用 Android API
我想在我的 libGDX 项目中使用 gdx-video 扩展来嵌入 YouTube 视频。我在 GitHub 上找到了这个扩展,但是在 Gradle 同步过程中有几条错误消息。我已将依赖项粘贴到 b
因此,我正在libgdx Wiki中进行简单的游戏操作,并且完成了这些操作,但出现了这些错误。 首先是: dropSound = new Gdx.audio.newSound(Gdx.files.in
我正在开发一款 Gdx 游戏,但我遇到了一些问题,我将简要解释一下: 我有 9 个球,按 3*3 排列,我需要检测我正在触摸的球,如下图所示: enter image description here
我正在使用 libgdx 构建一个滚动射击游戏。在 Windows 中,一切运行正常,但在 Android 上,我得到明显的抖动,帧率从没有声音的 61 fps avg 下降到有声音的 48-56 f
我们使用 libgdx 为我们在 Android 上的游戏进行图形渲染。似乎 libgdx 将来可以放弃对布局文件的支持。使用布局文件的缺点是解析它需要更长的时间。优点是使用它构建 UI 非常方便,而
我遇到了与 this question 中相同的问题,但那里的答案并没有解决我的问题。 我没有通过 gdxsetup.jar 创建项目,我只是包含了 gdx.jar 和 gdx-backend-and
我目前正在使用 gdx-freetype 库为我的游戏生成 BitmapFonts。这真的很方便,因为我可以用它来处理 Android 上的不同屏幕尺寸。问题是制作字体需要很长时间。在启动时,我生成了
我创建了一个新的 GDX 项目,添加了所有必要的配置,以便它按应有的方式运行。然而,问题是每当我关闭游戏窗口时,它都会显示以下错误: 任务 ':desktop:DesktopLauncher.main
我需要 Box2D GDX Android 的三角形定义。我会把宽度除以 3 还是有一个类?这是普通矩形的代码: _rect1 = CCSprite.sprite("Rec
我已经完成了 IAP 系统的设置,但我不知道如何检查用户是否实际拥有/已经购买了某种产品。使用适用于 Android 的 Google IAP Billing 我只是这样做了: Purchase IT
如何在不使用 libgdx 的情况下使用 gdx-bullet?这意味着如何在不使用完整 libgdx 库的情况下独立使用 gdx-bullet 扩展?使用 libgdx 对于数学来说是很好的。 当我
我已经使用Google App Store在Android上实现了gdx-pay的有效实施。我按照以下步骤进行操作:https://bitbucket.org/just4phil/gdxpayexam
当尝试执行这段代码时: public void load(String filename) { FileHandle file = Gdx.files.external(filename + "
我在 LibGDX 中遇到一个问题,当我调用 Gdx.input.getY() 时,它会选择一个位于应用程序相对于屏幕中心另一侧的像素。 public class Main extends Appli
我有一个预制的 json 文件,我想测试一下。这个 Json 文件将被修改,所以我想读/写。我注意到 internal 是只读的。所以我想将我的 Json 文件保存在本地存储中(通过 eclipse
我是一名优秀的程序员,十分优秀!