查看: 1864|回复: 1
打印 上一主题 下一主题

[3D动漫] Animation的常见属性及方法_教程

[复制链接]

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-7-16 15:33:17 |只看该作者 |倒序浏览

   
        
            Animation.Play播放

            
            
            
            
                function Play (mode : PlayMode = PlayMode.StopsameLayer) : bool

                 
                function Play (animation : string, mode : PlayMode = PlayMode.StopSameLayer) : bool
            
            
            复制代码
            Play()将开始播放名称为animation的动画,或者播放默认动画。动画会突然开始播放而没有任何混合。

            如果模式是PlayMode.StopSameLayer,那么所有在同一个层的动画将停止播放。如果模式是PlayMode.StopAll,那么所有当前在播放的动画将停止播放。

            如果动画已经在播放过程中,别的动画将停止但是动画不会回退到开始位置。

            如果动画没有被设置成循环模式,它将停止并且回退到开始位置。

            如果动画不能被播放(没有动画剪辑或者没有默认动画),Play()将返回false。
            
            
            
                // 播放默认动画。

                 
                animation.Play();

                 
               

                 
                // Plays the walk animation - stops all other animations in the same layer

                 
                // 播放walk动画 - 停止同一层的其他动画。

                 
                animation.Play("walk");

                 
                // Plays the walk animation - stops all other animations

                 
                // 播放walk动画 - 停止其他动画。

                 
                animation.Play("walk", PlayMode.StopAll);
            
            
            复制代码
            Animation.CrossFade淡入淡出

            
            
            
            
                function CrossFade (animation : string, fadeLength : float = 0.3F, mode : PlayMode = PlayMode.StopSameLayer) : void
            
            
            复制代码
            在一定时间内淡入名称为name的动画并且淡出其他动画。

            如果模式是PlayMode.StopSameLayer,在同一层的动画将在动画淡入的时候淡出。如果模式是PlayMode.StopAll,所有动画将在淡入的时候淡出。

            如果动画没有被设置成循环,它将停止并且在播放完成之后倒带至开始。
            
            
            
                // Fade the walk cycle in and fade all other animations in the same layer out.

                 
                // 淡入walk循环并且淡出同一层的所有其他动画。

                 
                // Complete the fade within 0.2 seconds.

                 
                // 在0.2秒之内完成淡入淡出。

                 
                animation.CrossFade("Walk", 0.2);
            
            
            复制代码
            
            
            
                // Makes a character contains a Run and Idle animation

                 
                // fade between them when the player wants to move

                 
                // 让一个角色包含Run和Idle动画,并且在玩家想移动的时候在他们之间淡入淡出。

                 
                function Update () {

                 
                        if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)

                 
                                animation.CrossFade("Run");

                 
                        else

                 
                                animation.CrossFade("Idle");

                 
                }
            
            
            复制代码
            Animation.Sample采样

            
            
            
            
                function Sample () : void

                 
                在当前状态对动画进行采样。

                 
                当你明确想设置一些动画状态并且对它取样一次的时候有用。

                 
                // Set up some state;

                 
                // 设置一些状态;

                 
                animation["MyClip"].time = 2.0;

                 
                animation["MyClip"].enabled = ***e;

                 
                // Sample animations now.

                 
                // 取样动画。

                 
                animation.Sample();

                 
               

                 
                animation["MyClip"].enabled = false;
            
            
            复制代码
            Animation.Stop 停止
            
            
            
                function Stop () : void
            
            
            复制代码
            
            
            
                // Stop all animations

                 
                //停止所有动画。

                 
                animation.Stop();
            
            
            复制代码
            Animation.this[string name]操作名字
            
            
            
                var this[name : string] : AnimationState
            
            
            复制代码
            
            
            
                // Get the walk animation state and set its speed

                 
                // 取得walk动画状态并设置其速度。

                 
                animation["walk"].speed = 2.0;

                 
               

                 
                // Get the***n animation state and set its weight

                 
                // 取***n动画状态并设置其重量。

                 
                animation[&quot***n"].weight = 0.5;
            
            
            复制代码
            Animation.wrapMode循环模式

            动画剪辑播放完成之后,应该如何操作?

            

            WrapMode.Default:从动画剪辑中读取循环模式(默认是Once)。

            WrapMode.Once:当时间播放到末尾的时候停止动画的播放。

            WrapMode.Loop:当时间播放到末尾的时候重新播放从开始播放。

            WrapMode.ClampForever:播放动画。当播放到结尾的时候,动画总是处于最后一帧的采样状态。
            
            
            
                //Make the animation loop

                 
                //使用动画循环模式。

                 
                animation.wrapMode = WrapMode.Loop;
            
            
            
            如果要查看其他属性及方法,请登录http://3d.ceeger.com/Script/Animation/Animation.wrapMode.html
        
   
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

2508

主题

2

听众

3万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
32806
精华
12

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2012-8-3 18:38:17 |只看该作者
我爱纳金网~www.narkii.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-2-13 16:17 , Processed in 0.068130 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部