打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Touch.phase
userphoto

2014.03.29

关注
Touch.phase
var phaseTouchPhase;

描述了触摸的相位。

在触摸阶段指的是手指已对最近的帧的更新的动作。由于接触被追踪设备在其“一生”,在之间的接触和动作的开始和结束可以报上发生的帧。的相位特性可以被用作一个“开关”语句的基础上,或作为更sophisitcated状态处理系统的一部分。

var startPos: Vector2;var direction: Vector2;var directionChosen: boolean;

function Update () { // Track a single touch as a direction control. if (Input.touchCount > 0) { var touch = Input.GetTouch(0); // Handle finger movements based on touch phase. switch (touch.phase) { // Record initial touch position. case TouchPhase.Began: startPos = touch.position; directionChosen = false; break; // Determine direction by comparing the current touch // position with the initial one. case TouchPhase.Moved: direction = touch.position - startPos; break; // Report that a direction has been chosen when the finger is lifted. case TouchPhase.Ended: directionChosen = true; break; } } if (directionChosen) { // Something that uses the chosen direction... }}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
第十二章:表视图常用UI范例
Unity 移动端触摸屏操作
Touch 触摸
贪吃蛇游戏源代码(C++)
HTML5获取位置信息
事件监听器中this指代问题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服