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{}
    
  • 相关阅读:
    Linux之Shell编程read读取控制台输入
    Linux之Shell编程while循环基本使用
    Linux之Shell编程for循环基本使用
    Linux之Shell编程case语句
    C语言 ##__VA_ARGS__
    C语言 __VA_ARGS__
    C语言 ##运算符
    C语言 __cplusplus
    C语言 #运算符
    C语言 extern “C”
  • 原文地址:https://www.cnblogs.com/kingBook/p/12971531.html
Copyright © 2011-2022 走看看