gpt4 book ai didi

java - 平板电脑中的 Libgdx 坐标系

转载 作者:行者123 更新时间:2023-11-29 03:11:11 28 4
gpt4 key购买 nike

我在我的旧手机 (Samsung Galaxy Ace) 上测试我的“游戏”,我把它给了我妈妈,所以我现在使用的是平板电脑 (Samsung GT-P7300),但我在当我触摸屏幕时的坐标。我在 AndroidManifest 中配置为纵向方向,所以当我测试游戏时,屏幕“躺下”(预期行为),但是当我触摸屏幕的左上角时,我的游戏日志显示倒置位置。或许你看图就明白了:

enter image description here

最佳答案

当您点击屏幕时,libgdx 使用屏幕坐标(y 向下)为您提供事件的确切像素。

如果你想让你的触摸以相机为单位(y-up),你必须unproject它。

Vector3 touch = new Vector3();

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button){
camera.unproject(touch.set(screenX, screenY, 0));
//touch.x and touch.y are your new touch point using camera coordinates.
...

关于java - 平板电脑中的 Libgdx 坐标系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29269504/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com