在代码中修改AnimationClip.wrapMode 无效

  • Creator 版本:1.9.0

  • 目标平台: Android

在属性检查器中添加了Animation 是component

添加了AnimationClip 名为 ‘sideGuideBoxShow’ ,

在动画编辑器中让sideGuideBoxShow作x位移动画.wrapMode选择Normal.

在JS中,按键触发播放动画.
onSideGuideBtnPressed(){ if (this.inScreen) { this.sideGuideGo(); } else{ this.sideGuideShow(); } },

sideGuideShow(){

    this.anim.play('sideGuideBoxShow');
    this.inScreen = true;
},

sideGuideGo(){ this.anim.play('sideGuideBoxShow'); this.inScreen = false; },

动画完成之后根据状态修改动画wrapMode.
afterAnim(){ if (this.inScreen) { this.anim.getClips()[0].wrapMode = 36; //将wrapMode设为Reverse } else{ this.anim.getClips()[0].wrapMode = 0; } },

可是设置完wrapMode之后,再次点击Button,(inScreen的default value 为 false),动画没有任何变化.还是播放Normal时的样子.问问各位大神为什么啊这是??

兄弟解决了吗?我这边是先设置只播放一次,再调用播放,然后再代码更改播放模为loop,再播放,结果只能播放一次

const {ccclass, property} = cc._decorator;

@ccclass
export default class AnimTest extends cc.Component {
    @property(cc.Animation)
    anim: cc.Animation = null;

    onLoad() {
        let state = this.anim.play();

        state.wrapMode = cc.WrapMode.Loop;
    }
}

这样写

3赞

感谢大佬 :+1: