描述了触摸的相位。
阶段
指的是手指已对最近的帧的更新的动作。由于接触被追踪设备在其“一生”,在之间的接触和动作的开始和结束可以报上发生的帧。的相位
特性可以被用作一个“开关”语句的基础上,或作为更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... }}
联系客服