zoukankan      html  css  js  c++  java
  • unity中手机触摸代码

    #elif UNITY_IOS || UNITY_ANDROID
            if(Input.touchCount <= 0)
            {
                return;//强制退出  不执行以下有关触摸的代码
            }
            if (Input.GetTouch(0).phase == TouchPhase.Began)
            {
                previousPositionX = Input.GetTouch(0).position.x;


                startAddSpeed = false;
                startAddSpeed_reduce = false;
                startReduceSpeed = false;
                ShowSpeed = 15f;
            }
            if (Input.GetTouch(0).phase == TouchPhase.Moved)
            {
                offset = Input.GetTouch(0).position.x - previousPositionX;
                if (Input.GetTouch(0).deltaPosition.x > 0)
                {
                    ShowSpeed = 55f;
                }
                else if (Input.GetTouch(0).deltaPosition.x < 0)
                {
                    ShowSpeed = -30f;
                }
                previousPositionX = Input.GetTouch(0).position.x;
            }
            if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                if (ShowSpeed < 15)
                {
                    startAddSpeed = true;
                    startAddSpeed_reduce = true;
                }
                else if (ShowSpeed > 15)
                {
                    startReduceSpeed = true;
                }
                mouseCurrentPos = Input.GetTouch(0).position;
                mouseIsMove = false;
            }
  • 相关阅读:
    javascript的alert的使用
    UIGestureRecognizer对图像进行缩放、移动、旋转操作
    对开源库使用 AutoCAD 文件格式
    计算机图形学常用算法
    KMP字符串模式匹配详解
    C++面试题String函数实现
    c++虚函数解析
    c++内存分配
    win32编程入门
    C++中Int转换成String
  • 原文地址:https://www.cnblogs.com/Study088/p/9568085.html
Copyright © 2011-2022 走看看