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

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

ID:47068281

大小:325.00 KB

页数:12页

时间:2019-07-14

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.//Optionally,youcanenable

3、thetouchPadpropertyfromtheeditor10.//totreatthisJoystickasaTouchPad.ATouchPadallowsthefinger11.//totouchdownatanypointandittracksthemovementrelatively12.//withoutmovingthegraphic13.//////////////////////////////////////////////////////////////14.  15.@scriptRequireCompone

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

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

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

7、/Fingerlastusedforthisjoystick10.privatevartapTimeWindow:float;                  //Howmuchtimethereisleftforataptooccur11.privatevarfingerDownPos:Vector2;12.privatevarfingerDownTime:float;13.privatevarfirstDeltaTime:float=0.5;14.  15.privatevargui:GUITexture;             

8、         //Joystickgraphic16.privatevardefaultRect:Rect;                      //Defaultposition/

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

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

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