unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动

unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动

ID:34726640

大小:359.18 KB

页数:12页

时间:2019-03-10

unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动_第1页
unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动_第2页
unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动_第3页
unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动_第4页
unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动_第5页
资源描述:

《unity3d游戏开发之ios自定义游戏摇杆与飞机平滑的移动》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、移动开发游戏中使用到的触摸游戏摇杆在iPhone上是非常普遍的,毕竟是全触摸屏手机,今天MOMO通过一个小例子和大家讨论unity3D中如何自定义一个漂亮的全触摸游戏摇杆。  出自狗刨学习网          值得高兴的是,unity3d 游戏引擎的标准资源中已经帮助我们封装了一个游戏摇杆脚本,所以实现部分的代码可以完全借助它的,具体调用需要我们自己来。    Joystick.js是官方提供的脚本,具体代码如下,有兴趣的朋友可以仔细研究研究,MOMO就不多说啦。哇咔咔~1.///////////////////////

2、///////////////////////////////////////2.//Joystick.js3.//PenelopeiPhoneTutorial4.//5.//Joystickcreatesamovablejoystick(viaGUITexture)that6.//handlestouchinput,taps,andphases.Deadzonescancontrol7.//wherethejoystickinputgetspickedupandcanbenormalized.8.//9.//Optio

3、nally,youcanenablethetouchPadpropertyfromtheeditor10.//totreatthisJoystickasaTouchPad.ATouchPadallowsthefinger11.//totouchdownatanypointandittracksthemovementrelatively12.//withoutmovingthegraphic13.//////////////////////////////////////////////////////////////14

4、.  15.@scriptRequireComponent(GUITexture)16.  17.//AsimpleclassforboundinghowfartheGUITexturewillmove18.classBoundary19.{20.  varmin:Vector2=Vector2.zero;21.  varmax:Vector2=Vector2.zero;22.}23.  24.staticprivatevarjoysticks:Joystick[];              //Astaticcoll

5、ectionofalljoysticks25.staticprivatevarenumeratedJoysticks:boolean=false;26.staticprivatevartapTimeDelta:float=0.3;          //Timeallowedbetweentaps1.  2.vartouchPad:boolean;                        //IsthisaTouchPad?3.vartouchZone:Rect;4.vardeadZone:Vector2=Vect

6、or2.zero;                //Controlwhenpositionisoutput5.varnormalize:boolean=false;                    //Normalizeoutputafterthedead-zone?6.varposition:Vector2;                        //[-1,1]inx,y7.vartapCount:int;                              //Currenttapcount8

7、.  9.privatevarlastFingerId=-1;                      //Fingerlastusedforthisjoystick10.privatevartapTimeWindow:float;                  //Howmuchtimethereisleftforataptooccur11.privatevarfingerDownPos:Vector2;12.privatevarfingerDownTime:float;13.privatevarfirstDel

8、taTime:float=0.5;14.  15.privatevargui:GUITexture;                      //Joystickgraphic16.privatevardefaultRect:Rect;                      //Defaultposition/

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。