Ejemplo n.º 1
0
	// Update is called once per frame
	void Update () {

		zoom = ZOOM.NONE;

		for (int i=0; i<MAX_TAP; i++) {
			// 指一本での処理
			if (Input.touchCount == i+1) {
				var touch = Input.GetTouch (i);
				
				switch (touch.phase) {
					// 開始
				case TouchPhase.Began:
					startPos[i] = touch.position;
					break;

					// 移動中
				case TouchPhase.Moved:
					direction[i] = touch.position - startPos[i];
					break;
					
					// 終了時
				case TouchPhase.Ended:
					endPos[i] = touch.position;
					if(i == 0)
						swipe = GetSwipe (i);
					startPos[i] = new Vector2 (0, 0);
					direction[i] = new Vector2 (0, 0);
					endPos[i] = new Vector2 (0, 0);
					break;
				}
			}

		}

		if (Input.touchCount == 0) {
			swipe = SWIPE.NONE;
			distance = 0;
		}
		if (Input.touchCount >= 2) {				
			distance = Vector2.Distance (Input.GetTouch (0).position, Input.GetTouch (1).position);
		
			if(oldDistance - distance < 0)
				zoom = ZOOM.ZOOM_IN;
			if(oldDistance - distance > 0)
				zoom = ZOOM.ZOOM_OUT;

			oldDistance = distance;

			swipe = SWIPE.NONE;
		}

	}
Ejemplo n.º 2
0
	// Use this for initialization
	void Start () {
		swipe = SWIPE.NONE;
		startPos = new Vector2[MAX_TAP];
		direction = new Vector2[MAX_TAP];
		endPos = new Vector2[MAX_TAP];
	}