iTween基础之Shake(摆动)

一、基础介绍;二、基础属性

原文地址 :http://blog.csdn.net/dingkun520wy/article/details/50836780

一、基础介绍

ShakePosition: 根据提供的amount衰减其值随机摇动游戏物体的位置,其晃动大小和方向由提供的amount决定

ShakeRotation:

 根据提供的amount衰减其值随机摆动旋转游戏物体的角度,其转动角度就是X,Y,Z的值的大小.

ShakeScale:根据提供的amount衰减其值随机摆动改变游戏物体的大小,其大小比例变化方向和大小由提供的Vector3决定.

 

二、基础属性

基础属性比较简单直接上代码

1,ShakePosition

[csharp] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. void Start () {  
  2.    
  3.         //键值对儿的形式保存iTween所用到的参数  
  4.         Hashtable args = new Hashtable();  
  5.         //摇摆的幅度  
  6.         //args.Add("amount", new Vector3(5, 5, 5));  
  7.         //args.Add("x", 20);  
  8.         args.Add("y",100);  
  9.         //args.Add("z", 2);  
  10.       
  11.         //是世界坐标系还是局部坐标系  
  12.         args.Add("islocal", true);  
  13.         //游戏对象是否将面向其方向  
  14.         args.Add("orienttopath", true);  
  15.         //面朝的对象  
  16.         //args.Add("looktarget", new Vector3(1, 1, 1));  
  17.         //args.Add("looktime", 5.0f);  
  18.           
  19.         //动画的整体时间。如果与speed共存那么优先speed  
  20.         args.Add("time", 1f);  
  21.         //延迟执行时间  
  22.         //args.Add("delay", 0.1f);  
  23.   
  24.         //三个循环类型 none loop pingPong (一般 循环 来回)    
  25.         //args.Add("loopType", "none");  
  26.         //args.Add("loopType", "loop");   
  27.         args.Add("loopType", iTween.LoopType.pingPong);  
  28.   
  29.   
  30.         //处理动画过程中的事件。  
  31.         //开始动画时调用AnimationStart方法,5.0表示它的参数  
  32.         args.Add("onstart", "AnimationStart");  
  33.         args.Add("onstartparams", 5.0f);  
  34.         //设置接受方法的对象,默认是自身接受,这里也可以改成别的对象接受,  
  35.         //那么就得在接收对象的脚本中实现AnimationStart方法。  
  36.         args.Add("onstarttarget", gameObject);  
  37.   
  38.   
  39.         //动画结束时调用,参数和上面类似  
  40.         args.Add("oncomplete", "AnimationEnd");  
  41.         args.Add("oncompleteparams", "end");  
  42.         args.Add("oncompletetarget", gameObject);  
  43.   
  44.         //动画中调用,参数和上面类似  
  45.         args.Add("onupdate", "AnimationUpdate");  
  46.         args.Add("onupdatetarget", gameObject);  
  47.         args.Add("onupdateparams", true);  
  48.   
  49.         iTween.ShakePosition(btnBegin, args);  
  50.           
  51.     }  
  52.       
  53.       
  54.     //动画开始时调用  
  55.     void AnimationStart(float f)  
  56.     {  
  57.         Debug.Log("start :" + f);  
  58.     }  
  59.     //动画结束时调用  
  60.     void AnimationEnd(string f)  
  61.     {  
  62.         Debug.Log("end : " + f);  
  63.   
  64.     }  
  65.     //动画中调用  
  66.     void AnimationUpdate(bool f)  
  67.     {  
  68.         Debug.Log("update :" + f);  
  69.           
  70.     }  

2,ShakeRotation
[csharp] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. void Start () {  
  2.    
  3.         //键值对儿的形式保存iTween所用到的参数  
  4.         Hashtable args = new Hashtable();  
  5.         //摇摆的幅度  
  6.         args.Add("amount", new Vector3(20, 100,0));  
  7.         //args.Add("x", 20);  
  8.         //args.Add("y",100);  
  9.         //args.Add("z", 2);  
  10.       
  11.         //是世界坐标系还是局部坐标系  
  12.         args.Add("space", Space.Self);  
  13.           
  14.           
  15.         //动画的整体时间。如果与speed共存那么优先speed  
  16.         args.Add("time", 1f);  
  17.         //延迟执行时间  
  18.         //args.Add("delay", 0.1f);  
  19.   
  20.         //三个循环类型 none loop pingPong (一般 循环 来回)    
  21.         //args.Add("loopType", "none");  
  22.         //args.Add("loopType", "loop");   
  23.         args.Add("loopType", iTween.LoopType.pingPong);  
  24.   
  25.   
  26.         //处理动画过程中的事件。  
  27.         //开始动画时调用AnimationStart方法,5.0表示它的参数  
  28.         args.Add("onstart", "AnimationStart");  
  29.         args.Add("onstartparams", 5.0f);  
  30.         //设置接受方法的对象,默认是自身接受,这里也可以改成别的对象接受,  
  31.         //那么就得在接收对象的脚本中实现AnimationStart方法。  
  32.         args.Add("onstarttarget", gameObject);  
  33.   
  34.   
  35.         //动画结束时调用,参数和上面类似  
  36.         args.Add("oncomplete", "AnimationEnd");  
  37.         args.Add("oncompleteparams", "end");  
  38.         args.Add("oncompletetarget", gameObject);  
  39.   
  40.         //动画中调用,参数和上面类似  
  41.         args.Add("onupdate", "AnimationUpdate");  
  42.         args.Add("onupdatetarget", gameObject);  
  43.         args.Add("onupdateparams", true);  
  44.   
  45.         iTween.ShakeRotation(btnBegin, args);  
  46.     }  
  47.       
  48.       
  49.     //动画开始时调用  
  50.     void AnimationStart(float f)  
  51.     {  
  52.         Debug.Log("start :" + f);  
  53.     }  
  54.     //动画结束时调用  
  55.     void AnimationEnd(string f)  
  56.     {  
  57.         Debug.Log("end : " + f);  
  58.   
  59.     }  
  60.     //动画中调用  
  61.     void AnimationUpdate(bool f)  
  62.     {  
  63.         Debug.Log("update :" + f);  
  64.           
  65.     }  

3,ShakeScale
[csharp] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. void Start () {  
  2.    
  3.         //键值对儿的形式保存iTween所用到的参数  
  4.         Hashtable args = new Hashtable();  
  5.         //摇摆的幅度  
  6.         args.Add("amount", new Vector3(2,0,0));  
  7.         //args.Add("x", 20);  
  8.         //args.Add("y",100);  
  9.         //args.Add("z", 2);  
  10.       
  11.           
  12.         //动画的整体时间。如果与speed共存那么优先speed  
  13.         args.Add("time", 1f);  
  14.         //延迟执行时间  
  15.         //args.Add("delay", 0.1f);  
  16.   
  17.         //三个循环类型 none loop pingPong (一般 循环 来回)    
  18.         //args.Add("loopType", "none");  
  19.         //args.Add("loopType", "loop");   
  20.         args.Add("loopType", iTween.LoopType.pingPong);  
  21.   
  22.   
  23.         //处理动画过程中的事件。  
  24.         //开始动画时调用AnimationStart方法,5.0表示它的参数  
  25.         args.Add("onstart", "AnimationStart");  
  26.         args.Add("onstartparams", 5.0f);  
  27.         //设置接受方法的对象,默认是自身接受,这里也可以改成别的对象接受,  
  28.         //那么就得在接收对象的脚本中实现AnimationStart方法。  
  29.         args.Add("onstarttarget", gameObject);  
  30.   
  31.   
  32.         //动画结束时调用,参数和上面类似  
  33.         args.Add("oncomplete", "AnimationEnd");  
  34.         args.Add("oncompleteparams", "end");  
  35.         args.Add("oncompletetarget", gameObject);  
  36.   
  37.         //动画中调用,参数和上面类似  
  38.         args.Add("onupdate", "AnimationUpdate");  
  39.         args.Add("onupdatetarget", gameObject);  
  40.         args.Add("onupdateparams", true);  
  41.   
  42.         iTween.ShakeScale(btnBegin, args);  
  43.     }  
  44.       
  45.       
  46.     //动画开始时调用  
  47.     void AnimationStart(float f)  
  48.     {  
  49.         Debug.Log("start :" + f);  
  50.     }  
  51.     //动画结束时调用  
  52.     void AnimationEnd(string f)  
  53.     {  
  54.         Debug.Log("end : " + f);  
  55.   
  56.     }  
  57.     //动画中调用  
  58.     void AnimationUpdate(bool f)  
  59.     {  
  60.         Debug.Log("update :" + f);  
  61.           
  62.     }  

更多unity3d动画基础 http://blog.csdn.net/dingkun520wy/article/details/50550529
原文地址:https://www.cnblogs.com/lexiaoyao-jun/p/5258990.html