creator 动态远程加载龙骨


creator 动态远程加载龙骨

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
loadRemoteDragonbones(armatureName, animationName, target){
let baseUrl = Common.s_remote_resource_url + "resources/dragonbone/" + armatureName + "/" + armatureName;
let bone = {
bone_ske: baseUrl + "_ske.json",
bone_tex : baseUrl + "_tex.json",
bone_tex_img: baseUrl + "_tex.png"
};
cc.loader.load([bone.bone_ske, bone.bone_tex, bone.bone_tex_img], (err, results) => {
let _dragonAsset = new dragonBones.DragonBonesAsset();
// @ts-ignore
_dragonAsset._uuid = bone.bone_ske;
_dragonAsset.dragonBonesJson = JSON.stringify(results.getContent(bone.bone_ske));
let _dragonAtlasAsset = new dragonBones.DragonBonesAtlasAsset();
// @ts-ignore
_dragonAtlasAsset._uuid = bone.bone_tex;
_dragonAtlasAsset.atlasJson = JSON.stringify(results.getContent(bone.bone_tex));
_dragonAtlasAsset.texture = results.getContent(bone.bone_tex_img);

target.m_armatureDisplay.dragonAsset = _dragonAsset;
target.m_armatureDisplay.dragonAtlasAsset = _dragonAtlasAsset;

target.m_armatureDisplay.armatureName = armatureName;
target.m_armatureDisplay.playAnimation(animationName, 1);
target.m_armatureDisplay.node.active = true;

target.m_armatureDisplay.addEventListener(dragonBones.EventObject.FADE_IN_COMPLETE, target.animationEventHandler, target);
target.m_armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, target.animationEventHandler, target);

target.m_armatureDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT, target.frameEventHandler, target);
target.m_armatureDisplay.addEventListener(dragonBones.EventObject.SOUND_EVENT, target.frameEventHandler, target);

});
}