交互:

Drag Gesture

Type : Continuous

Configuration class: GestureConfigDrag

Event class: GestureEventDrag

Action description:The user touched the screen, performed a translation and withdraw its finger(s).

Comments: The number of finger on the screen cannot vary during the gesture. The programmer can modify the MinimumDragDistance field if he need the gesture to be triggered for smaller drags.

配置类:GestureConfigDrag
事件类:GestureEventDrag
动作描述:用户触摸屏幕时,进行了翻译和撤回手指(s)。
评论:手指在屏幕上的数量不能改变姿态。程序员可以修改MinimumDragDistance字段如果他需要被触发的动作小拖。

Flick Gesture

Type : Discrete

Configuration class: GestureConfigFlick

Event class: GestureEventFlick

Action description:The user touched the screen, performed a quick straight translation and withdraw its finger(s).

Comments: The number of finger on the screen cannot vary during the gesture. The programmer can modify the MinimumFlickLength field to constrain the flick to have a minimum length.

类型:离散
配置类:GestureConfigFlick
事件类:GestureEventFlick
动作描述:用户触摸屏幕时,执行一个快速直接翻译和撤回手指(s)。
评论:手指在屏幕上的数量不能改变姿态。程序员可以修改MinimumFlickLength字段来限制有一个最小长度的电影。

Long Press Gesture

Type : Discrete

Configuration class: GestureConfigLongPress

Event class: GestureEventLongPress

Action description:The user touched the screen, and maintained the pressure without moving during a given time (default about 1 second).

Comments: The number of finger on the screen cannot vary during the gesture. The programmer can modify the RequiredPressTime field to change the press time.

长按手势
类型:离散
配置类:GestureConfigLongPress
事件类:GestureEventLongPress
动作描述:用户触摸屏幕,保持不动的压力在一个给定的时间(默认约1秒)。
评论:手指在屏幕上的数量不能改变姿态。程序员可以修改RequiredPressTime字段改变新闻时间。

Composite Gesture

Type : Continuous

Configuration class: GestureConfigComposite

Event class: GestureEventComposite

Action description:The user touched the screen with two fingers, and moved them independently.

Comments: This gesture is a composition the 3 basic transformations translation, scale, rotation. It requires exactly 2 fingers on the screen. The gesture is triggered when the system detect a small translation, scale or rotation. To perform a translation, the user translates uniformly the two fingers together. To perform a scale, the user moves closer or further the two fingers from each other. To perform a rotation, the user turns the two fingers around there their middle.

复合动作
类型:连续
配置类:GestureConfigComposite
事件类:GestureEventComposite
动作描述:用户用两个手指触摸屏幕,并独立地移动。
评论:这个手势是三个基本成分转换翻译,规模、旋转。它需要2根手指在屏幕上。触发手势当系统检测到一个小翻译,规模或旋转。进行翻译时,用户将统一在一起的两根手指。执行规模、用户移动接近或进一步的两根手指。执行一个旋转,用户就那里的两个手指在他们的中间。

Tap Gesture

Type : Discrete

Configuration class: GestureConfigTap

Event class: GestureEventTap

Action description:The user touched the screen, and removed its fingers quickly without moving.

Comments: The number of finger on the screen cannot vary during the gesture.The programmer can modify the RequiredNumberOfTaps field to decide the number tap that he wants to detect. Note that to be able to distinguish single taps from multi-tap taps, the system has to wait a given time and thus introduces latency in tap events. If the programmer is interested only in single taps, he can put the MaximumTimeBetweenTaps field to 0 to avoid this latency.

点击手势
类型:离散
配置类:GestureConfigTap
事件类:GestureEventTap
动作描述:用户触摸屏幕,并删除其手指快速不动。
评论:手指在屏幕上的数量不能改变姿态。程序员可以修改RequiredNumberOfTaps字段决定利用他想检测数量。注意,能够区分单从转接插座水龙头水龙头,系统必须等待一个给定的时间,因此介绍了延时水龙头事件。如果程序员只对单一的水龙头感兴趣,他可以把MaximumTimeBetweenTaps字段为0来避免这种延迟。

Usage

By default, the input system does not recognize any Gesture. To start (resp. stop) some gesture recognition the programmer has to add (resp. remove) gesture configurations to the @'SiliconStudio.Xenko.Input.ActivatedGestures' collection. Once a gesture is activated for recognition, its associated configuration is frozen and the user cannot modify it any more. If the user wants to stop all gesture recognition he can directly clear the collection.

Code: Activate/Desactivate Gestures Recognitions

var singleTapConfig = new GestureConfigTap(); // create the configuration of the gesture we want to recognize
Input.ActivatedGestures.Add(singleTapConfig); // start the tap gesture recognition var doubleTapConfig = new GestureConfigTap(2, 1); // create the configuration of the gesture we want to recognize
Input.ActivatedGestures.Add(doubleTapConfig ); // start the double tap gesture recognition // ... Input.ActivatedGestures.Remove(singleTapConfig); // stop the tap gesture recognition // ...
Input.ActivatedGestures.Clear(); // stop all remaining gesture recognitions

Each configuration class has a parameterless constructor corresponding to the default gesture configuration. Special constructors have also been implemented for parameters that the programmer may modify frequently. Other parameters correspond to fields that are not recommended to modify to keep a good coherency of the system. Those fields can be modified by accessing the corresponding properties.

Code: Set gesture configuration

var singleTapConfig = new GestureConfigTap(); // default config for the gesture.
var doubleTapConfig = new GestureConfigTap(2, 2); // personalize the gesture config by using the dedicated constructor
var noLatencyTap = new GestureConfigTap() { MaximumTimeBetweenTaps= TimeSpan.Zero }; // personalize the gesture config by directly accessing the desired property (user must be aware of was he does, this may break the input system coherency in some cases)

The programmer can access the recognized gestures via the @'SiliconStudio.Xenko.Input.IInputManager.GestureEvents' collections. The collection is automatically cleared every frame.

Code: Access Gesture events

var currentFrameGestureEvents = Input.GestureEvents;

One can use the Type field to identity the gesture type and then cast it to the appropriate event type to have extra info about the event.

Code: Identifying the gesture type

foreach( var gestureEvent in Input.GestureEvents)
{
if (gestureEvent.Type != GestureType.Tap) // determine if the event is from a tap gesture
continue; GestureEventTap tapEvent = (GestureEventTap) gestureEvent; // cast the event the specific tap event class
log.Info("Tap position: {0}.", tapEvent.TapPosition); // access tap event specific field
}

One can know the gesture state by analyzing the @' SiliconStudio.Xenko.Input.GestureEvent.State' field.

Code: Identifying the event state

switch(compositeGestureEvent.State)
{
case GestureState.Began:
image.ComputePreview();
break;
case GestureState.Changed:
image.TransformPreview(compositeGestureEvent.TotalScale, compositionGestureEvent.TotalRotation);
break;
case GestureState.Ended:
image.TransformRealImage(compositeGestureEvent.TotalScale, compositionGestureEvent.TotalRotation);
break;
default:
break;
}

Xenko基础API笔记2-手势的更多相关文章

  1. Xenko基础API笔记3- Pointers指针设备屏幕上点对应的手指触摸。

    样本这里是一个简单的示例程序,跟踪目前在屏幕上的指针和打印他们的位置.访问输入字段,类继承自@ SiliconStudio.Xenko.脚本的类. public override async Task ...

  2. Xenko基础API笔记2-Enum Keys按键

    Name   Description A The 'a' key. Add The 'add' key. Apps The 'apps' key. Attn The 'attn' key. B The ...

  3. UICollectionView基础API笔记

    UICollectionView系列API,属性含义笔记.在UICollectionView笔记1中我们了解了UICollectionView是什么,以及可以做什么:在UICollectionView ...

  4. jQuery官方基础教程笔记(转载)

    本文转载于阮一峰的博文,内容基础,结构清晰,是jquery入门不可多得的资料,非常好,赞一个. 阮一峰:jQuery官方基础教程笔记 jQuery是目前使用最广泛的javascript函数库. 据统计 ...

  5. Java基础学习笔记总结

    Java基础学习笔记一 Java介绍 Java基础学习笔记二 Java基础语法之变量.数据类型 Java基础学习笔记三 Java基础语法之流程控制语句.循环 Java基础学习笔记四 Java基础语法之 ...

  6. C#RabbitMQ基础学习笔记

    RabbitMQ基础学习笔记(C#代码示例) 一.定义: MQ是MessageQueue,消息队列的简称(是流行的开源消息队列系统,利用erlang语言开发).MQ是一种应用程序对应用程序的通信方法. ...

  7. 尚学堂JAVA基础学习笔记

    目录 尚学堂JAVA基础学习笔记 写在前面 第1章 JAVA入门 第2章 数据类型和运算符 第3章 控制语句 第4章 Java面向对象基础 1. 面向对象基础 2. 面向对象的内存分析 3. 构造方法 ...

  8. SpringCloud基础概念学习笔记(Eureka、Ribbon、Feign、Zuul)

    SpringCloud基础概念学习笔记(Eureka.Ribbon.Feign.Zuul) SpringCloud入门 参考: https://springcloud.cc/spring-cloud- ...

  9. Java基础复习笔记系列 九 网络编程

    Java基础复习笔记系列之 网络编程 学习资料参考: 1.http://www.icoolxue.com/ 2. 1.网络编程的基础概念. TCP/IP协议:Socket编程:IP地址. 中国和美国之 ...

随机推荐

  1. c# 映射对比测试

    c#  映射对比测试(测试对象,测试案例,测试结果) 测试组件对象: TinyMapper-EmitMapper-AutoMapper-NLiteMapper-Handwritten 对比测试案例: ...

  2. Vim找不到配色文件的解决方法

    Vim新出了8.0,又成功的勾起了我的好奇心. 重新从零开始配置,结果第一步设置配色主题就没过,好丢人-- 提示找不到evening.vim配色文件,于是上网查了一下,有说改环境变量的,又说改这个改那 ...

  3. weex环境搭建

    1. 安装weex-toolkit sudo npm install -g weex-toolkit 装完之后就可以使用weex命令了.输入weex命令可以看到: weex test.we --qr ...

  4. JavaScriptPolyfillShim 在JavaScript中Shim和Polyfill有什么区别?

    在JavaScript的世界里,有两个词经常被提到,那就是Shim和Polyfill,它们指的都是什么,又有什么区别?在本文中,将简短的给大家介绍他们之间的联系和区别.Shim一个shim就是一个库, ...

  5. 控制器(Controller) – ASP.NET MVC 4 系列

           创建一个 ASP.NET MVC 4 Web Application 项目,将程序命名为 MvcMusicStore,如下图: 控制器        MVC 模式中,控制器主要负责响应用 ...

  6. ANDROID学习之路 转

    版权声明:本文为 stormzhang 原创文章,可以随意转载,但必须在明确位置注明出处!!! 这篇博客背后的故事 一路走来很不容易,刚好知乎上被人邀请回答如何自学android编程, 就借这个机会在 ...

  7. 为什么上传文件的表单里面要加一个属性enctype=multipart/form-data?

    首先知道enctype这个属性管理的是表单的MIME编码.共有三个值可选:1.application/x-www-form-urlencoded2.multipart/form-data3.text/ ...

  8. cPage分页,asp.net自定义分页,url传值分页,支持datalist、gridview、Repeater等

    asp.net分页是最最常用的功能,实现方式也很多,使用不同的控件有不同的分页方式. 下面分享一个我们团队内部使用了多年的一个分页控件cPage,是自己设计编写,没有冗余,简单.快速. cPage,现 ...

  9. WM_MOUSELEAVE和WM_MOUSEHOVER使用

      默认情况下,窗口是不响应 WM_MOUSELEAVE 和 WM_MOUSEHOVER 消息的,所以要使用 _TrackMouseEvent 函数来激活这两个消息.调用这个函数后,当鼠标在指定窗口上 ...

  10. 基于Spring Boot/Spring Session/Redis的分布式Session共享解决方案

    分布式Web网站一般都会碰到集群session共享问题,之前也做过一些Spring3的项目,当时解决这个问题做过两种方案,一是利用nginx,session交给nginx控制,但是这个需要额外工作较多 ...