</pre>做飞天小老鼠2D游戏中的记录。<p></p><p>这个是原文链接:http://www.tairan.com/archives/7430</p><p>下面写一下收获。</p><p>第一天收获:1.<span style="white-space:pre"> </span>rigidbody2D.AddForce(new Vector2(0,packForce));</p><p><span style="white-space:pre"></span><span style="white-space:pre"></span>重要的是这个函数,它能在X 和 Y方向上添加一个力;</p><p><span style="white-space:pre"></span>2.</p><p><span style="white-space:pre"></span>在我们想让两个精灵对齐时可以按V键,来选中一个支点;</p><p>第二天:1.<span style="white-space:pre"> </span>计算屏幕宽度的方法:</p><pre name="code" class="csharp">float height = 2.0f * Camera.main.orthographicSize;
screenWidthInPoints = height * Camera.main.aspect;
2. 为了检测floor与老鼠的碰撞,设置floor的layermask为“grounded”;然后以老鼠的中心为原点建立半径为0.1的圆,使用函数
Physics2D.OverlapCircle (groundedCheck.position, 0.1f, groundCheckMask);检测是否与floor有接触,有的话返回true,否则返回false;