Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Libgdx CameraController限制区域_Libgdx - Fatal编程技术网

Libgdx CameraController限制区域

Libgdx CameraController限制区域,libgdx,Libgdx,我使用了许多输入控制器。一个用于控制摄影机,另一个用于控制已放置在场景中的按钮 我一直在尝试如何创建自己的自定义控制器,但到目前为止还没有找到任何关于如何创建的教程 此外,如果触摸或手势低于某个高度,我想停用相机控制器 非常感谢您的帮助只需创建一个类即可CamController实现InputProcessor(或扩展InputAdapter)。 然后覆盖所有需要的方法(我使用着陆作为示例)并执行以下操作(伪代码!!!不要复制和粘贴!!!): 您只需将输入多路复用器设置为活动的输入处理器 使用C

我使用了许多输入控制器。一个用于控制摄影机,另一个用于控制已放置在场景中的按钮

我一直在尝试如何创建自己的自定义控制器,但到目前为止还没有找到任何关于如何创建的教程

此外,如果触摸或手势低于某个高度,我想停用相机控制器


非常感谢您的帮助

只需创建一个类即可
CamController实现InputProcessor
(或
扩展InputAdapter
)。
然后覆盖所有需要的方法(我使用
着陆
作为示例)并执行以下操作(伪代码!!!不要复制和粘贴!!!):

您只需将
输入多路复用器
设置为活动的
输入处理器

使用
CamController
作为第一个方法很重要,因为它随后会为此调用
touchtdown
-方法,并且只有
touchtdown
返回false时,才会调用
ButtonController

希望能有帮助

protected boolean touchDown(int screenX, int screenY, int pointer, int button) {
    boolean handled = false;
    if (screenX <= maxX && screenX >= minX && screenY <= maxY && screenY >= minY) {
         // The touch is inside the limits of the camera controller, the controller is activated
         // Move camera to the touchpoint:
         camera.position.set(screenX, screenY);
         camra.update();
         handled = true;
    }
    return handled;
}
InputMultiplexer m = new InputMultiplexer(new CamController(camera, limitX, limitY), new ButtonController);