Beispiel #1
0
 /// <summary>
 /// 押された
 /// </summary>
 /// <param name="e">PointerEventData</param>
 public void OnPointerDown(PointerEventData e)
 {
     isRunning = true;
     SetType(EventType.Pressed);
     startPos  = GodTouch.GetPosition();
     startTime = Time.time;
 }
Beispiel #2
0
 /// <summary>
 /// 更新処理
 /// </summary>
 void Update()
 {
     if (type == EventType.Pressed)
     {
         // 押されてる
         var pos = GodTouch.GetPosition();
         var dx  = Mathf.Abs(pos.x - startPos.x);
         var dy  = Mathf.Abs(pos.y - startPos.y);
         var dt  = Time.time - startTime;
         if (dx > CheckDistance || dy > CheckDistance)
         {
             // 一定距離動いていたらドラッグ実行
             SetType(EventType.Drag);
         }
         else if (dt > CheckTime)
         {
             // 一定時間経過していたら長押し実行
             SetType(EventType.LongPress);
         }
     }
     else if (type == EventType.Drag)
     {
         // ドラッグ中(動かす)
         transform.position = GodTouch.GetPosition();
     }
 }
        // Update is called once per frame
        void Update()
        {
            //float limitHorizontal = 0.0f;
            var phase = GodTouch.GetPhase();

            if (phase == GodPhase.Began)
            {
                //タッチ開始処理
                startPos = GodTouch.GetPosition();
                //startRot = rb.transform.rotation;
            }
            else if (phase == GodPhase.Moved)
            {
                horizontal = (GodTouch.GetPosition().x - startPos.x) / width;  //横移動量(-1<tx<1)
                vertical   = (GodTouch.GetPosition().y - startPos.y) / height; //縦移動量(-1<ty<1)
                //limitVertical = Mathf.Clamp(vertical, 0.1f, 0.5f);
                //obj.transform.rotation = startRot;
                //obj.transform.Rotate(new Vector3(90 * ty, -90 * tx, 0), Space.World);
                rb.angularVelocity = new Vector3(90 * vertical, -90 * horizontal, 0);
            }
            else if (phase == GodPhase.Ended)
            {
                //タッチ終了
                Debug.Log("TouchEnded");
            }
            else
            {
                limitVertical = 0.1f;
            }

            //rb.angularVelocity = new Vector3(90 * limitVertical, -90 * horizontal, 0);
        }
Beispiel #4
0
        private void Flick()
        {
            var phase = GodTouch.GetPhase();

            if (phase == GodPhase.Began)
            {
                startPos = GodTouch.GetPosition();
            }
            if (phase == GodPhase.Ended)
            {
                endPos = GodTouch.GetPosition();
                GetDireciton();
            }
        }
Beispiel #5
0
        // Update is called once per frame
        private void Update()
        {
            var phase = GodTouch.GetPhase();

            vY = -1.0f;

            //タッチされたときとあとの処理
            if (phase == GodPhase.Began)
            {
                //タッチ開始
                sPos = GodTouch.GetPosition().x;
            }
            else if (phase == GodPhase.Ended)
            {
                //タッチされた場所の開始位置と最終位置を比較して上ならspeedを上げる
                //下ならspeedを下げる
                ePos    = GodTouch.GetPosition().x;
                trigger = true;
            }

            //タッチされている間の処理
            if (phase == GodPhase.Stationary)
            {
                Debug.Log("Idle");
                vY = -0.2f;
                vX = 0f;
            }
            else if (Input.GetMouseButton(0))
            {
                Debug.Log("Idle");
                vY = -0.2f;
                vX = 0f;
            }

            if (sPos > ePos && trigger)
            {
                vX      = Mathf.Clamp(vX += 0.3f, -1.0f, 1.0f);
                trigger = false;
                Debug.Log(vX);
            }
            else if (sPos < ePos && trigger)
            {
                vX      = Mathf.Clamp(vX -= 0.3f, -1.0f, 1.0f);
                trigger = false;
                Debug.Log(vX);
            }
            rb.angularVelocity = new Vector3(vY, vZ, vX);
        }
        // Update is called once per frame
        void Update()
        {
            var phase = GodTouch.GetPhase();

            if (phase == GodPhase.Began)
            {
                startPos = GodTouch.GetPosition();
                startRot = stage.transform.rotation;
            }
            else if (phase == GodPhase.Moved)
            {
                horizontal = (GodTouch.GetPosition().x - startPos.x) / width;
                vertical   = (GodTouch.GetPosition().y - startPos.y) / height;
                stage.transform.rotation = startRot;
                stage.transform.Rotate(new Vector3(90 * vertical, -90 * horizontal, 0), Space.World);
            }
        }
Beispiel #7
0
        void Update()
        {
            if (ClickLongPressDrag.IsRunning)
            {
                return;                                           // 他のサンプルが動作してる時は無効
            }
            // タッチを検出して動かす
            var phase = GodTouch.GetPhase();

            if (phase == GodPhase.Began)
            {
                startPos = Move.position;
            }
            else if (phase == GodPhase.Moved)
            {
                Move.position = GodTouch.GetPosition();
//				Move.position += GodTouch.GetDeltaPosition();
            }
            else if (phase == GodPhase.Ended)
            {
                Move.position = startPos;
            }
        }