我的模拟器上的 LibGDX 显示原点 (0,0) 在左下角,但我的设备在左上方。请帮忙!
我修改了两个屏幕的教程作为我的程序,并使用font.draw()
在屏幕上绘制字体作为菜单。字体绘制工作正常,但实现 InputProcessor
的 touchup + touchDown
事件在设备和模拟器上提供了不同的系统来源。
emulator: Android 4.0.3 level 15
device: Samsung Galaxy Nexus, android 4.2.1.
我应该从 LibGDX 切换到 OpenGL ES 2 吗?
非常感谢!
最诚挚的问候。
最佳答案
InputProcessor 中的 touchup 和 touchdown 事件为您提供您单击的实际像素以及设备屏幕单位。从左上角开始。您应该始终unproject您对相机坐标的触摸。
创建 Vector3:
Vector3 touchPoint = new Vector3();
使用相机取消投影:
@Override public boolean touchDown(int screenX, int screenY, int pointer, int button){ cam.unproject(touchPoint.set(screenX, screenY, 0));
然后使用 touchPoint.x 和 touchPoint.y 作为触摸坐标。
关于java - libgdx 系统源在设备和模拟器上不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20629744/