Commit 926ee851 authored by 范雪寒's avatar 范雪寒

fix: animeNode为空的check

parent d75cd232
...@@ -193,14 +193,6 @@ cc.Class({ ...@@ -193,14 +193,6 @@ cc.Class({
optionNode.x = posNode.x * optionPosListBase.scaleX; optionNode.x = posNode.x * optionPosListBase.scaleX;
optionNode.y = posNode.y; optionNode.y = posNode.y;
const animeNode = await asyncLoadDragonBoneAnime(cc.find('OptionDragonBoneBaseNode', optionNode), data.optionDragonBone);
animeNode.scale = Math.min(260 / animeNode.width, 360 / animeNode.height, 1);
animeNode.name = 'animeNode';
animeNode.addComponent(cc.Button);
animeNode.on('click', () => {
this.onOptionClicked(optionNode, idx);
});
const btnFlower = cc.find('OptionSpeakerBtn/BtnFlower', optionNode); const btnFlower = cc.find('OptionSpeakerBtn/BtnFlower', optionNode);
const btnFlowerP = cc.find('OptionSpeakerBtn/BtnFlower_P', optionNode); const btnFlowerP = cc.find('OptionSpeakerBtn/BtnFlower_P', optionNode);
const optionSpeakerBtn = cc.find('OptionSpeakerBtn', optionNode); const optionSpeakerBtn = cc.find('OptionSpeakerBtn', optionNode);
...@@ -218,11 +210,25 @@ cc.Class({ ...@@ -218,11 +210,25 @@ cc.Class({
blinkNode(optionNode, btnFlowerP, btnFlower); blinkNode(optionNode, btnFlowerP, btnFlower);
await asyncPlayEffectByUrl(data.optionAudio); await asyncPlayEffectByUrl(data.optionAudio);
const animeNode = await asyncLoadDragonBoneAnime(cc.find('OptionDragonBoneBaseNode', optionNode), data.optionDragonBone);
if (animeNode) {
asyncPlayDragonBoneAnimation(animeNode, 'normal', 1); asyncPlayDragonBoneAnimation(animeNode, 'normal', 1);
}
stopBlinkNode(optionNode, btnFlowerP, btnFlower); stopBlinkNode(optionNode, btnFlowerP, btnFlower);
optionSpeakerBtn.canNotClick = false; optionSpeakerBtn.canNotClick = false;
}); });
const animeNode = await asyncLoadDragonBoneAnime(cc.find('OptionDragonBoneBaseNode', optionNode), data.optionDragonBone);
if (!animeNode) {
return;
}
animeNode.scale = Math.min(260 / animeNode.width, 360 / animeNode.height, 1);
animeNode.name = 'animeNode';
animeNode.addComponent(cc.Button);
animeNode.on('click', () => {
this.onOptionClicked(optionNode, idx);
});
}); });
}, },
...@@ -240,7 +246,9 @@ cc.Class({ ...@@ -240,7 +246,9 @@ cc.Class({
onOptionWrong(optionNode) { onOptionWrong(optionNode) {
const animeNode = cc.find('OptionDragonBoneBaseNode/animeNode', optionNode); const animeNode = cc.find('OptionDragonBoneBaseNode/animeNode', optionNode);
if (animeNode) {
animeNode.color = cc.color(150, 150, 150, 255); animeNode.color = cc.color(150, 150, 150, 255);
}
playEffect('wrong'); playEffect('wrong');
}, },
...@@ -264,9 +272,11 @@ cc.Class({ ...@@ -264,9 +272,11 @@ cc.Class({
if (option != optionNode) { if (option != optionNode) {
const animeNode = cc.find('OptionDragonBoneBaseNode/animeNode', option); const animeNode = cc.find('OptionDragonBoneBaseNode/animeNode', option);
if (animeNode) {
animeNode.color = cc.color(255, 255, 255, 255); animeNode.color = cc.color(255, 255, 255, 255);
asyncPlayDragonBoneAnimation(animeNode, 'normal', -1); asyncPlayDragonBoneAnimation(animeNode, 'normal', -1);
} }
}
}); });
}, },
......
...@@ -247,7 +247,8 @@ export function addButtonListener(btnNode, func) { ...@@ -247,7 +247,8 @@ export function addButtonListener(btnNode, func) {
export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJsonDataUrl }, texJsonData: { url: texJsonDataUrl }, texPngData: { url: texPngDataUrl } }) { export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJsonDataUrl }, texJsonData: { url: texJsonDataUrl }, texPngData: { url: texPngDataUrl } }) {
if (!texPngDataUrl || !texJsonDataUrl || !texPngDataUrl) { if (!texPngDataUrl || !texJsonDataUrl || !texPngDataUrl
|| texPngDataUrl == '' || texJsonDataUrl == '' || texPngDataUrl == '') {
return; return;
} }
...@@ -263,29 +264,6 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs ...@@ -263,29 +264,6 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay); const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
// cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => {
// cc.assetManager.loadAny({ url: texJsonDataUrl }, (error, atlasJson) => {
// cc.assetManager.loadAny({ url: skeJsonDataUrl }, (error, dragonBonesJson) => {
// const atlas = new dragonBones.DragonBonesAtlasAsset();
// atlas.atlasJson = JSON.stringify(atlasJson);
// atlas.texture = texture;
// const asset = new dragonBones.DragonBonesAsset();
// asset.dragonBonesJson = JSON.stringify(dragonBonesJson);
// dragonDisplay.dragonAtlasAsset = atlas;
// dragonDisplay.dragonAsset = asset;
// let armatureNames = dragonBonesJson.armature.map(data => data.name);
// if (armatureNames.length > 0) {
// dragonDisplay.armatureName = armatureNames[0];
// }
// resolve(animaNode);
// });
// });
// });
const loadTexture = new Promise((resolve, reject) => { const loadTexture = new Promise((resolve, reject) => {
cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => { cc.assetManager.loadRemote(texPngDataUrl, (error, texture) => {
if (error) { if (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment