- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我敢肯定这是非常简单的事情。我的大脑严重卡住。我一直在反转它,从中减去,乘以它,添加到它。不管是上是下还是下是上。
if (Gdx.input.isButtonPressed(Buttons.LEFT)) s.drawCirc(c, Gdx.input.getX(), Gdx.input.getY(), 100, 100);
x 轴很好,罪魁祸首是 Gdx.input.getY()
。当我向上移动手指时,它会向下移动,向下移动时会向上移动。
我的圆圈在中间排成一行,但当我向上时它会下降,当我向下时它会上升。我想了解这里到底发生了什么以及为什么会发生。(当然还有如何修复它)
如果你需要知道 c
是我的相机,这里是代码以防这是罪魁祸首
c = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
在我使用的drawCirc
方法中
shapeRenderer.setProjectionMatrix(c.combined);
最佳答案
这是因为用于输入的坐标系和相机使用的坐标系在y轴上是相反的。理想情况下,在获取输入时,您希望将输入取消投影到相机,以便所有坐标都很好地对齐。您可以使用 c.unproject(input)
执行此操作。这是一个代码示例:
if (Gdx.input.isButtonPressed(Buttons.LEFT))
{
Vector3 input = new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0);
cam.unproject(input);
//Now you can use input.x and input.y, as opposed to Gdx.input.getX() and
//Gdx.input.getY(), to draw the circle
s.drawCirc(c, input.x, input.y, 100, 100);
}
关于java - LibGDX down为up up为down gdx.input.getY(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23144655/
我正在尝试计算 WriteHTMLCell 框的高度。我想我可以使用调用 WriteHTMLCell() 前后 Y 位置之间的差异.... $start_y = $pdf->GetY(); $p
当我按窗口左上角附近的某个位置时,由于某种原因,输出结果为 e.getY()比 e.getX() 高约 40 。我不明白为什么...你呢?我对 e.getY() 不太清楚. //BBDemo.java
这是一个很长的问题。我已尽力使其更加简洁,但我认为您需要所有信息来提供帮助。 总结如下:我正在 try catch 连续点击作为端点。我将在这些点之间绘制 line2D 对象。我有一个监听器,它将点击
我在 JFrame 中嵌入了一个 JPanel。 JPanel被添加到BorderLayout的CENTER。我正在使用以下代码对其进行绘制,但 MouseEvent 的 getX() 和 getY(
我在 LibGDX 中遇到一个问题,当我调用 Gdx.input.getY() 时,它会选择一个位于应用程序相对于屏幕中心另一侧的像素。 public class Main extends Appli
好吧,我没什么可说的,但基本上我有一个 Player 类,然后在 GFX 类中我用它绘制 Player他的 getX() 和 getY() 所以 player.getX() 正如你所看到的,我制作了
这个问题在这里已经有了答案: Android ACTION_MOVE Threshold (3 个答案) 关闭 8 年前。 当读取一系列 onTouch 事件的 getX() 和 getY() 值时
我试图通过 onClickListener() 使一个 ImageView 移动到另一个 ImageView 的相同位置,我可以返回 x 但不能返回 y。 我要复制的 View 位置在 xml 中是不
GUI 组件的位置、宽度和高度何时设置?如果使用布局管理器,这些字段会受到怎样的影响?我有一个包含两个 slider 的面板,我想在其中一个 slider 旁边绘制一个矩形。下面是我的代码,用于初始化
在我解释文档时,getY()应该返回矩形的左上角 Y 坐标;即最大的Y坐标。但是,当调用 getMaxY() (继承自 RectangularShape 类)我得到了一个更大的值! 在代码中: Pat
我似乎不太了解 android View 中 getTop() 和 getY() 之间的区别。它们有何不同? 最佳答案 getTop() 返回相对于父级的 y 坐标。 getY() 像 getTop(
我正在尝试制作一个简单的应用程序,以便更好地了解如何在 Android 上使用触摸事件。现在,我的 Activity 只是将 ImageView 移动到屏幕上触摸的坐标(MotionEvent 的坐标
我需要帮助来理解以下内容。 假设我有一个 854x480 像素的显示器。为什么 MotionEvent.getX 和 getY 方法返回 float ?据我所知,显示器上的像素是离散整数,显示器上没有
有很多关于 MotionEvent.getX/.getY 如何“不可靠”(或其他术语)以及我们应该使用这些调用的原始版本来获取坐标的讨论。 在我的 Nexus 7 上,我发现 .getX/.getY
我有两个 ImageView。我想将一个移动到另一个之上。 当我尝试检索 ImageView 位置之一的值以将另一个移动到它时,我在 x 和 y 上都得到 0。 我尝试使用 getLeft/getTo
我正在编写一个基本的绘画程序,但我在 Rectangle 方面遇到了麻烦。和Ellipse工具。如果单击并拖动,您应该能够根据 startpoint 绘制尺寸的形状。和endpoint (都使用 ge
这是一项更大的家庭作业。如何使用 getX() 和 getY() 绘制一条线?这是我的代码,请帮忙。 package shapes; import java.awt.Color; import jav
我正在尝试创建一种方法来计算两个 Point 对象之间的距离: public class Point { private double x; private double y;
我有以下情况: 我有一个带有 ImageView 和 TextView 的自定义 ListView。ImageView 有一个 onTouchListener,它调用我的 onTouch 方法。以下是
本文整理了Java中us.ihmc.yoVariables.variable.YoFrameVector3D.getY()方法的一些代码示例,展示了YoFrameVector3D.getY()的具体用
我是一名优秀的程序员,十分优秀!