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{}
    
  • 相关阅读:
    luffy后台登录+注册+课程
    luffy前台登录+注册+课程
    luffy前台准备
    luffy后台准备
    跨域请求
    pip源和虚拟环境的搭建
    Book接口
    drf-Xadmin的使用
    drf-JWT认证
    drf-自动生成接口文档
  • 原文地址:https://www.cnblogs.com/kingBook/p/12971531.html
Copyright © 2011-2022 走看看