zoukankan      html  css  js  c++  java
  • 动画循环播放

    
    
    #pragma strict
    
    var t1:boolean=false;
    var t2:boolean=false;
    var t3:boolean=false;
    var currentTime:float;
    var indvel:float;
    
    function Start(){
       currentTime = Time.time;
       t1 = true;
    }
       
    function Update(){
      Play();
    }
       
    function Play() {
     if(t1){ 
           animation.CrossFade("Run",0.2,PlayMode.StopAll);
        if(Time.time>currentTime+indvel*2) {
            if(!t2)t2=true;
         if(t1) t1=false;
         currentTime=Time.time;
        }
    }
    else if(t2){
        animation.CrossFade("Walk",0.2,PlayMode.StopAll);
     if(Time.time>currentTime+indvel/2) {
            if(t2)t2=false;
         if(!t3) t3=true;
         currentTime=Time.time;
        }
    }
    else if(t3){
        animation.CrossFade("Idle",0.2,PlayMode.StopAll);
     if(Time.time>currentTime+indvel) {
            if(t3)t3=false;
         if(!t1) t1=true;
         currentTime=Time.time;
        }
    }
     
    }
    
    
    
    #pragma strict
    var AN:Animation;
    var bool = true;
    var ani:String = "can";
    function Start () {
       bool = true;
      AN =  GetComponent.<Animation>();
      print(animation["Run"].clip.length);
      
        do{
          yield StartCoroutine(ani);
        }while(true);
    }
    
    function Update(){
       if(bool)
        ani = "can";
        else
        ani = "to";
        
    }
    
    function can(){
       yield StartCoroutine("doit");
        yield StartCoroutine("ro");
    }
    
    function doit(){
       AN.CrossFade("Run",0.2);
       yield WaitForSeconds (animation["Run"].clip.length*2);
    }
    
    function ro(){
       AN.CrossFade("Walk",0.2);// Wait for the animation to have finished
       yield WaitForSeconds (animation["Walk"].clip.length*2);
    }
    
    function to(){
    
       AN.CrossFade("Idle",0.2);// Wait for the animation to have finished
       //yield WaitForSeconds (animation["Walk"].clip.length*5);
    }


     

  • 相关阅读:
    spring 条件装配
    git 工作用命令
    tomcat 在 server.xml 中配置数据源
    rancher + harbor + jenkins 自动化部署
    FHS 文件体系标准
    linux常用命令
    linux常用工具
    ts-node 执行报错,Cannot find module '@types/node/package.json'
    npm 安装报错 gyp: No Xcode or CLT version detected!
    css中的层级问题(z-index)
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2605613.html
Copyright © 2011-2022 走看看