位置: 编程技术 - 正文
推荐整理分享地铁跑酷操控程序解析(地铁酷跑瞬间移动),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:地铁酷跑技巧,地铁跑酷zoe,地铁跑酷操作,地铁跑酷没有技巧不翻滚不跳跃,地铁跑酷技能讲解,地铁跑酷操控程序破解版,地铁跑酷操控程序破解版,地铁跑酷操控程序破解版,内容如对您有帮助,希望把文章链接给更多的朋友!
public class Swipe { // Fields public Vector3 end; public float endTime; public Vector3 start; public float startTime; }2.四个滑动方向的枚举 public enum SwipeDir { Up, Down, Left, Right, None }3.监听Touch输入,得到输入的Swipe public void HandleControls() { if (!this._paused && (Input.touchCount > 0)) { Touch touch = Input.touches[0]; if (touch.phase == TouchPhase.Began) { this.currentSwipe = new Swipe(); this.currentSwipe.start = (Vector3) touch.position; this.currentSwipe.startTime = Time.time; } if ((((touch.phase == TouchPhase.Moved) || (touch.phase == TouchPhase.Ended)) || (touch.phase == TouchPhase.Canceled)) && (this.currentSwipe != null)) { this.currentSwipe.endTime = Time.time; this.currentSwipe.end = (Vector3) touch.position; SwipeDir swipeDir = this.AnalyzeSwipe(this.currentSwipe); if (swipeDir != SwipeDir.None) { if (this.characterState != null) { this.characterState.HandleSwipe(swipeDir); } this.currentSwipe = null; } } if ((touch.phase == TouchPhase.Ended) && (this.currentSwipe != null)) { this.currentSwipe.endTime = Time.time; this.currentSwipe.end = (Vector3) touch.position; if ((this.AnalyzeSwipe(this.currentSwipe) == SwipeDir.None) && (this.characterState != null)) { this.HandleTap(); } } } }4.处理、分析得到是Swip;通过向量的点乘,得到沿上下左右四个方向上分量做多的那个方向,作为最终结果。 private SwipeDir AnalyzeSwipe(Swipe swipe) { Vector3 b = Camera.main.ScreenToWorldPoint(new Vector3(swipe.start.x, swipe.start.y, 2f)); if (Vector3.Distance(Camera.main.ScreenToWorldPoint(new Vector3(swipe.end.x, swipe.end.y, 2f)), b) < this.swipe.distanceMin) { return SwipeDir.None; } Vector3 lhs = swipe.end - swipe.start; SwipeDir none = SwipeDir.None; float num2 = 0f; float num3 = Vector3.Dot(lhs, Vector3.up); if (num3 > num2) { num2 = num3; none = SwipeDir.Up; } num3 = Vector3.Dot(lhs, Vector3.down); if (num3 > num2) { num2 = num3; none = SwipeDir.Down; } num3 = Vector3.Dot(lhs, Vector3.left); if (num3 > num2) { num2 = num3; none = SwipeDir.Left; } num3 = Vector3.Dot(lhs, Vector3.right); if (num3 > num2) { num2 = num3; none = SwipeDir.Right; } return none; }地铁跑酷的操控手感灰常好,多多学习,多多借鉴。
用简单的方法做整套UI(教程第一/二/三弹合集)
解决粒子特效被NGUI遮挡的问题 最近给UI添加粒子特效时,总是被UI遮挡,解决方法是:因为粒子系统的渲染顺序列默认为,而NGUI的渲染顺序默认也是从开始,当有嵌套的panel时
unity中对象池运用 最近在研究对象池在unity中的运用对象池,通常用于在那些需要经常创建又销毁的对象比如我们场景中的小怪,经常需要创建和销毁,我们就可以在小怪
标签: 地铁酷跑瞬间移动
本文链接地址:https://www.jiuchutong.com/biancheng/381461.html 转载请保留说明!友情链接: 武汉网站建设