UNITY之iTween

来源:互联网 发布:二叉树中序非递归算法 编辑:程序博客网 时间:2024/05/16 04:14
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
    public Texture2D textsure;
    public Vector3[] vecs;
    // Use this for initialization
    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"));
        Hashtable hash = new Hashtable ();
        hash.Add ("time",5);
        hash.Add ("x",10);
        hash.Add ("looptype",iTween.LoopType.pingPong);
        hash.Add ("oncomplete","OnAnimationComplete");
        hash.Add ("easetype",iTween.EaseType.easeInExpo);
        //hash.Add ("oncompleteparams","nihao");给OnAnimationComplete(string msg)方法传递参数
         iTween.MoveTo (this.gameObject,hash);
        //iTween.ColorTo (this.gameObject,iTween.Hash("r",0,"g",255,"b",0,"includechildren",true));//从原来颜色变换为目标颜色
        //iTween.ColorFrom (this.gameObject,Color.black,3);//从此颜色变换回原来颜色
        //iTween.CameraFadeAdd (textsure);//必须添加一张2d纹理
        //iTween.CameraFadeFrom (1,3);//摄像机的透明度从1到0
        //iTween.CameraFadeTo (1,3);//摄像机的透明度从0到1
        //iTween.ScaleTo (this.gameObject,iTween.Hash("time",3,"x",5));
        //iTween.PunchPosition (this.gameObject,iTween.Hash("time",2,"x",2,"y",2));
        //iTween.ShakePosition (this.gameObject,iTween.Hash("time",5,"x",2,"y",2));
    }

    void OnDrawGizmos(){
        iTween.DrawLine (vecs,Color.red);//绘制一条线链接Vector3[] vecs中的各点;
        //iTween.DrawPath (vecs,Color.red);//绘制一条路径链接Vector3[] vecs中的各点
    }
    // Update is called once per frame
    void Update () {
        //iTween.MoveUpdate (this.gameObject,Vector3.up*Time.deltaTime,2);
    }
    void OnAnimationComplete(){
        print ("nihao OnAnimationComplete");
    }
//    void OnAnimationComplete(string msg){
//        print (msg);
//    }

}


using UnityEngine;
using System.Collections;
public class RotateDemo : MonoBehaviour {
    public GameObject target;
    // Use this for initialization
    void Start () {
        //looktarget:朝向的目标物体,path:运行轨道
        iTween.MoveTo (this.gameObject,iTween.Hash("time",10,"looktarget",target.transform,"path",iTweenPath.GetPath("New Path 1"),
            "oncomplete","method","easetype",iTween.EaseType.easeInExpo
        ));
    }
    // Update is called once per frame
    void Update () {
    }
    void method(){//主要用来对摄像机的复原
    }
}

0 0