zoukankan      html  css  js  c++  java
  • Cocos Creator 动画控制

    //即使playOnLoad=true,也必须调用play函数播放一个动画,currentClip属性才会赋值
    let animation=this.getComponent(cc.Animation);
    animation.playOnLoad=true;
    cc.log(animation.currentClip);//ouput: null
    animation.play("idle");
    cc.log(animation.currentClip.name);//ouput: idle
    
    //每帧都调用play方法播放一个动画时,必须判断要播放的剪辑是否已是当前剪辑,否则会一直播放停止在第一帧
    if(animation.currentClip.name!="walk"){
          animation.play("walk");
    }
    
    let animationState=animation.play("idle");
    animationState.time;//动画播放的时间(注意:播放循环的的动画剪辑时,播放完成一遍后不会重置0)
    

    侦听循环的动画剪辑播放完成

    let animation=this.getComponent(cc.Animation);
    let animationState=animation.play("idle");
    animationState.wrapMode=cc.WrapMode.Loop;
    animationState.repeatCount=0;//设置循环的次数,0表示只播放一次(则不需要去设置wrapMode)
    animation.on("finished",this.onFinished,this);
    //private onFinished():void{}
    
  • 相关阅读:
    图片音乐 上传、下载
    表格类型数据,Excel csv导入,导出操作
    逐行读取txt文件,分割,写入txt。。。上传,下载
    性能分析四
    性能分析三
    postman断言
    postman+Newman语法参数
    shell_03
    shell_02
    shell_01
  • 原文地址:https://www.cnblogs.com/kingBook/p/12971531.html
Copyright © 2011-2022 走看看