unity3d 手机中Input类中touch详解_教程
来源:互联网 发布:qq飞车布鲁斯沃特数据 编辑:程序博客网 时间:2024/06/05 10:18
1.Input.touchCount 触摸随之增长 一秒50次增量
2.Input.GetTouch(0).phase==TouchPhase.Moved 手指滑动中最后一帧滑动的状态 是 运动的
3.TouchPhase 触摸的几个状态
4.Touch.deltaPosition 增量位置 (Input.GetTouch(0).deltaPosition)最后一帧滑动的值 只返回xy轴坐标 也可用vector3(z轴为0) 所以一般用vector2接收
--------------------------------复制代码touchCount指的是触摸帧的数量。
要注意的是:touch事件 只能在模拟器或者真机上运行(已测试通过) 大约一秒钟touch不放 touchCount+50次左右
2.Input.touches 触摸列表复制代码3.让cube 随着touch 移动代码:
2.Input.GetTouch(0).phase==TouchPhase.Moved
3.TouchPhase
4.Touch.deltaPosition 增量位置
--------------------------------
- static var aa:int;
- function Update () {
-
if(Input.touchCount>0) -
{ -
print(Input.touchCount); -
} - }
- function OnGUI()
- {
-
GUI.Label(Rect(34,34,34,34),"sdff"); - }
要注意的是:touch事件 只能在模拟器或者真机上运行(已测试通过) 大约一秒钟touch不放
2.Input.touches 触摸列表
- // Prints number of fingers touching the screen
- //输出触摸在屏幕上的手指数量
- function Update () {
-
var fingerCount = 0; -
for (var touch : Touch in Input.touches) { -
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) -
fingerCount++; -
} -
if (fingerCount > 0) -
print ("User has " + fingerCount + " finger(s) touching the screen"); - }
- static var count:int; //定义touchCount数
- var particle_:GameObject;//定义存放cube对象
- var touchposition:Vector3; //存储移动三维坐标值
- function Update () {
-
if(Input.touchCount>0) -
{ -
count+=Input.touchCount; -
-
} -
if((Input.touchCount>0&&Input.GetTouch(0).phase==TouchPhase.Moved)) //[color=Red]如果点击手指touch了 并且手指touch的状态为移动的[/color] -
{ -
touchposition=Input.GetTouch(0).deltaPosition; //[color=Red]获取手指touch最后一帧移动的xy轴距离[/color] -
particle_.transform.Translate(touchposition.x*0.01,touchposition.y*0.01,0);//[color=Red]移动这个距离[/color] -
} -
-
- }
- function OnGUI()
- {
-
GUI.Label(Rect(10,10,100,30),"cishu:"+count.ToString()); -
GUI.Label(Rect(10,50,100,30),touchposition.ToString()); - }
0 0
- unity3d 手机中Input类中touch详解_教程
- unity3d 手机中Input类中touch详解_教程
- Unity3D手机中Input类touch详解
- Input.GetAxis _ Unity3d
- Unity3D教程:Unity3D中网格合并示例
- 批处理中使用adb input event实现touch解锁
- linux中touch命令参数详解
- 详解Cocos2d CCLayer中Touch使用方法
- 详解Cocos2d CCLayer中Touch使用方法
- Android 中与 Touch 事件详解
- unity3d 中控制手机前后摄像头切换
- Unity3D中手机陀螺仪的使用
- Unity3D中手机陀螺仪的使用
- Unity3d中获取手机中的摄像头
- Unity3D手机斗地主游戏开发实战(03)_地主牌显示和出牌逻辑(不定期更新中~~~)
- Unity3D教程:调用C++中DLL文件
- Unity3D教程:调用C++中DLL文件
- unity3d 5.6烘焙教程 持续更新中
- 欢迎使用CSDN-markdown编辑器
- 如何让 Git 使用 HTTP 代理服务器
- leetcode 第145题 Binary Tree Postorder Traversal
- OC语言三大特性
- 计算灰度共生矩阵
- unity3d 手机中Input类中touch详解_教程
- 五元素把握页面文字舒适感
- G1 垃圾收集器入门
- 第11周 项目3 点类派生直线类
- struts2的session的用法
- AOP的annotation实现方式是基于AspectJ的实现
- 程序调用的方式
- Gevent的socket协程安全性分析
- 直方图相似性计算