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{}
    
  • 相关阅读:
    Eclipse中插件的运用
    AES加密解密 Java中运用
    DES加密解密 Java中运用
    Chrome中的插件运用
    JqueryEasyUI教程入门篇
    SEO入门教程
    屏幕取色工具
    gif处理
    java 实现序列化的两种方式
    重定向输出 > 1>&2 2>&1
  • 原文地址:https://www.cnblogs.com/kingBook/p/12971531.html
Copyright © 2011-2022 走看看