ITween

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);

}

}这里写代码片

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值