using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public Texture2D texture;//???
public Vector3[] vecs;
public GameObject go;
void Start () {
//iTween.MoveTo (this.gameObject,Vector3.up*5,3);
iTween.MoveTo (this.gameObject,iTween.Hash("time",5,"x",10,
"looptype",iTween.LoopType.pingPong
,"oncomplete","OnAnimationComplete",
"oncompleteparams","sss"));
/*"oncomplete","OnAnimationComplete"运动时所调用的函数OnAnimationComplete,
"oncompleteparams","sss"给所调用的函数传的参数sss*/
Hashtable hash = new Hashtable ();//hash 用于存储信息。
hash.Add ("x",5);
hash.Add ("time",2);
hash.Add ("looptype",iTween.LoopType.pingPong );//LoopType 循环移动的类型:loop,noun,pingPong
iTween.MoveTo (this.gameObject, hash);
//颜色变换
iTween.ColorTo (this.gameObject,iTween.Hash("time",1,"r",0,"g",255,"b",0,"includechildren",false));//includechildren子节点是否一起改变颜
iTween.ColorFrom (this.gameObject,Color.black,1);
//iTween.CameraFadeAdd (texture);//????
//iTween.CameraFadeFrom (1,3);
//iTween.CameraFadeTo (1, 3);
iTween.MoveTo (this.gameObject, iTween.Hash ("time", 5, "looktarget", go.transform,
"path", iTweenPath.GetPath ("New Path 1"),
"oncomplete", "Method"));
/*oncomplete->Method为物体运动结束时调用的函数名;iTweenPath.GetPath("PathName"),建一个空对象,添加
脚本 ITween Path,对Node路径节点进行调整;
looktarget,物体运动时,所对准的目标。
*/
}
void Method(){
print ("hello");
}
void OnDrawGizmos(){//关于绘制的操作必须写在该函数内
iTween.DrawLine (vecs,Color.red);//绘制直线,标志
iTween.DrawPath (vecs,Color.blue);//绘制曲线,边缘化直线
}
void Update () {
iTween.ScaleTo (this.gameObject, iTween.Hash (//改变比例
"time", 3,
"x", 5
));
iTween.PunchPosition (this.gameObject,iTween.Hash(//给物体一个弹力
"time",1,
"x",2,
"y",0
));
iTween.ShakePosition(this.gameObject,iTween.Hash(//使物体震动
"time",1,
"y",1
));
iTween.MoveBy (this.gameObject,Vector3.up*5,3);
//在Updata中可一直运动,而MoveTo不能,只运行一次。两者在Start中都只能运行一次。
//iTween.MoveUpdate (this.gameObject,Vector3.up*Time.deltaTime,2);
}
void OnAnimationComplete(string s){
Debug.Log ("Complete");
Debug.Log (s);
//iTween.ColorTo (this.gameObject,Color.red,1);
}
}这里写代码片