zoukankan      html  css  js  c++  java
  • 9.3、Libgdx手势检测

    (官网:www.libgdx.cn

    触摸屏在输入的基础上增加了手势检测,比如两个手指实现缩放,单击或双击屏幕,长按屏幕等。

    Libgdx提供了GestureDetector来帮助你检测以下手势:

    • touchDown:用户触摸屏幕。

    • longPress:用户长按屏幕。

    • tap:用户点击屏幕。手指必须在点击初始化的位置不能移动太大。

    • pan:用户滑动手指穿过屏幕。

    • panStop:当pan结束时调用。

    • fling:用户滑动手指穿过屏幕,然后释放。通常是用于滑动检测。

    • zoom:用户使用两个手指移动。

    GestureDetector是事件处理的一种方式。为了监听手势,比如实现GestureListener 接口,并将其传递给GestureDetector的构造器:

    public class MyGestureListener implements GestureListener{
    @Override
    public boolean touchDown(float x, float y, int pointer, int button) {
    return false;
    }
    @Override
    public boolean tap(float x, float y, int count, int button) {
    return false;
    }
    @Override
    public boolean longPress(float x, float y) {
    return false;
    }
    @Override
    public boolean fling(float velocityX, float velocityY, int button) {
    return false;
    }
    @Override
    public boolean pan(float x, float y, float deltaX, float deltaY) {
    return false;
    }
    @Override
    public boolean panStop(float x, float y, int pointer, int button) {
    return false;
    }
    @Override
    public boolean zoom (float originalDistance, float currentDistance){
    return false;
    }
    @Override
    public boolean pinch (Vector2 initialFirstPointer, Vector2 initialSecondPointer, Vector2 firstPointer, Vector2 secondPointer){
    return false;
    }
    }

    Gdx.input.setInputProcessor(new GestureDetector(new MyGestureListener()));

    www.libgdx.cn版权所有,如需转载,注明出处)

  • 相关阅读:
    PHP 5 echo 和 print 语句
    MySQL存储过程-遍历游标的例子
    bzoj2554: Color
    win10 uwp 入门
    win10 uwp 入门
    win10 uwp 自定义控件 SplitViewItem
    win10 uwp 自定义控件 SplitViewItem
    win10 uwp ContentDialog 点确定不关闭
    win10 uwp ContentDialog 点确定不关闭
    win10 uwp smms图床
  • 原文地址:https://www.cnblogs.com/hainange/p/6153496.html
Copyright © 2011-2022 走看看