19alanbknowles69 / colonist

Automatically exported from code.google.com/p/colonist
0 stars 1 forks source link

动态化移动按钮 #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
现在左下角的移动按钮位置是固定的.

把它改动为: 
由用户的手指下落在屏幕的那一刻,来决定操作基准点.

Original issue reported on code.google.com by yinyuanq...@gmail.com on 15 Dec 2012 at 12:13

GoogleCodeExporter commented 9 years ago
只对Joystick_Predator.cs进行改动
1.将Awake,Start,Update三处的JoyButtonBound计算代码注释
2.加入新的计算函数
    public static Rect GetSquareOnGUICoordinate(Vector2 position, float edgeLength)
    {
        return new Rect(position.x - edgeLength / 2, Screen.height - position.y - edgeLength / 2, edgeLength, edgeLength);
    }
3.重写onTouchBegin,增加一行计算JoyButtonBound代码
4.重写CheckTouch,当hasFingerOnJoyButton==false的时候返回true,否则执��
�base.CheckTouch(t);
5.改动OnGUI代码:原来的代码需要满足hasFingerOnJoyButton条件才执�
��

PS:改动后的代码文件稍后传到GDRIVE

Original comment by lightnin...@gmail.com on 15 Dec 2012 at 6:01