龙骨文件动态绑定,获取armatrue类为空

  • Creator 版本:
    2.0.10

  • 目标平台:
    web

  • 详细报错信息,包含调用堆栈:
    armatrue()调用输出为undefind

  • 重现方式:
    用下述提供代码运行即可,Bone为放了龙骨文件的文件夹在resource中

  • 编辑器之前是否有其它报错 :

  • 出现概率:
    必现

  • 额外线索:
    --------------------------源码-------------------------------------------------(armatrue()调用输出为undefind)
    let key = this.nodeBone.getComponent(dragonBones.ArmatureDisplay);
    key.timeScale = 1;
    key.animationName = null;
    cc.loader.loadResDir(“Bone”, function (err, assets) {
    assets.forEach(res => {
    if (res instanceof dragonBones.DragonBonesAsset) {
    key.dragonAsset = res;
    }
    if (res instanceof dragonBones.DragonBonesAtlasAsset) {
    key.dragonAtlasAsset = res;
    }
    })
    });
    key.armatureName = “armatureName”;
    cc.log(key.armature())

请参考creator自带的测试例 dragonbones/DragonMesh,验证并没有复现问题

this.dragonBone = animNode.addComponent(dragonBones.ArmatureDisplay);
this.dragonBone.armatureName = ‘hit’;//armatureName
this.dragonBone.playAnimation(‘hit_up’, 0);//stand
请问下我这样写应该也没问题吧,倒是无法切换呢,麻烦帮我看下