iTween基础之Shake(摆动)

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

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

一、基础介绍

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

ShakeRotation:

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

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


二、基础属性

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

1,ShakePosition

void Start () {
 
        //键值对儿的形式保存iTween所用到的參数
        Hashtable args = new Hashtable();
        //摇摆的幅度
        //args.Add("amount", new Vector3(5, 5, 5));
        //args.Add("x", 20);
        args.Add("y",100);
        //args.Add("z", 2);
    
        //是世界坐标系还是局部坐标系
        args.Add("islocal", true);
        //游戏对象是否将面向其方向
        args.Add("orienttopath", true);
        //面朝的对象
        //args.Add("looktarget", new Vector3(1, 1, 1));
        //args.Add("looktime", 5.0f);
        
        //动画的总体时间。假设与speed共存那么优先speed
        args.Add("time", 1f);
        //延迟运行时间
        //args.Add("delay", 0.1f);

        //三个循环类型 none loop pingPong (一般 循环 来回)	
        //args.Add("loopType", "none");
        //args.Add("loopType", "loop");	
        args.Add("loopType", iTween.LoopType.pingPong);


        //处理动画过程中的事件。
        //開始动画时调用AnimationStart方法,5.0表示它的參数
        args.Add("onstart", "AnimationStart");
        args.Add("onstartparams", 5.0f);
        //设置接受方法的对象,默认是自身接受,这里也能够改成别的对象接受,
        //那么就得在接收对象的脚本中实现AnimationStart方法。
        args.Add("onstarttarget", gameObject);


        //动画结束时调用,參数和上面相似
        args.Add("oncomplete", "AnimationEnd");
        args.Add("oncompleteparams", "end");
        args.Add("oncompletetarget", gameObject);

        //动画中调用。參数和上面相似
        args.Add("onupdate", "AnimationUpdate");
        args.Add("onupdatetarget", gameObject);
        args.Add("onupdateparams", true);

        iTween.ShakePosition(btnBegin, args);
        
    }
    
    
    //动画開始时调用
    void AnimationStart(float f)
    {
        Debug.Log("start :" + f);
    }
    //动画结束时调用
    void AnimationEnd(string f)
    {
        Debug.Log("end : " + f);

    }
    //动画中调用
    void AnimationUpdate(bool f)
    {
        Debug.Log("update :" + f);
        
    }

2,ShakeRotation

void Start () {
 
        //键值对儿的形式保存iTween所用到的參数
        Hashtable args = new Hashtable();
        //摇摆的幅度
        args.Add("amount", new Vector3(20, 100,0));
        //args.Add("x", 20);
        //args.Add("y",100);
        //args.Add("z", 2);
    
        //是世界坐标系还是局部坐标系
        args.Add("space", Space.Self);
        
        
        //动画的总体时间。假设与speed共存那么优先speed
        args.Add("time", 1f);
        //延迟运行时间
        //args.Add("delay", 0.1f);

        //三个循环类型 none loop pingPong (一般 循环 来回)	
        //args.Add("loopType", "none");
        //args.Add("loopType", "loop");	
        args.Add("loopType", iTween.LoopType.pingPong);


        //处理动画过程中的事件。
        //開始动画时调用AnimationStart方法,5.0表示它的參数
        args.Add("onstart", "AnimationStart");
        args.Add("onstartparams", 5.0f);
        //设置接受方法的对象,默认是自身接受。这里也能够改成别的对象接受,
        //那么就得在接收对象的脚本中实现AnimationStart方法。

args.Add("onstarttarget", gameObject); //动画结束时调用。參数和上面相似 args.Add("oncomplete", "AnimationEnd"); args.Add("oncompleteparams", "end"); args.Add("oncompletetarget", gameObject); //动画中调用。參数和上面相似 args.Add("onupdate", "AnimationUpdate"); args.Add("onupdatetarget", gameObject); args.Add("onupdateparams", true); iTween.ShakeRotation(btnBegin, args); } //动画開始时调用 void AnimationStart(float f) { Debug.Log("start :" + f); } //动画结束时调用 void AnimationEnd(string f) { Debug.Log("end : " + f); } //动画中调用 void AnimationUpdate(bool f) { Debug.Log("update :" + f); }


3,ShakeScale

void Start () {
 
        //键值对儿的形式保存iTween所用到的參数
        Hashtable args = new Hashtable();
        //摇摆的幅度
        args.Add("amount", new Vector3(2,0,0));
        //args.Add("x", 20);
        //args.Add("y",100);
        //args.Add("z", 2);
    
        
        //动画的总体时间。

假设与speed共存那么优先speed args.Add("time", 1f); //延迟运行时间 //args.Add("delay", 0.1f); //三个循环类型 none loop pingPong (一般 循环 来回) //args.Add("loopType", "none"); //args.Add("loopType", "loop"); args.Add("loopType", iTween.LoopType.pingPong); //处理动画过程中的事件。 //開始动画时调用AnimationStart方法。5.0表示它的參数 args.Add("onstart", "AnimationStart"); args.Add("onstartparams", 5.0f); //设置接受方法的对象,默认是自身接受,这里也能够改成别的对象接受。 //那么就得在接收对象的脚本中实现AnimationStart方法。 args.Add("onstarttarget", gameObject); //动画结束时调用。參数和上面相似 args.Add("oncomplete", "AnimationEnd"); args.Add("oncompleteparams", "end"); args.Add("oncompletetarget", gameObject); //动画中调用。參数和上面相似 args.Add("onupdate", "AnimationUpdate"); args.Add("onupdatetarget", gameObject); args.Add("onupdateparams", true); iTween.ShakeScale(btnBegin, args); } //动画開始时调用 void AnimationStart(float f) { Debug.Log("start :" + f); } //动画结束时调用 void AnimationEnd(string f) { Debug.Log("end : " + f); } //动画中调用 void AnimationUpdate(bool f) { Debug.Log("update :" + f); }


很多其它unity3d动画基础 http://blog.csdn.net/dingkun520wy/article/details/50550529


posted @ 2017-07-14 19:36  zsychanpin  阅读(210)  评论(0编辑  收藏  举报