Commit 3d22ca50 authored by 李维's avatar 李维

Bug fix

parent fc5f6b3c
This diff is collapsed.
...@@ -167,8 +167,11 @@ export default class Cartoon { ...@@ -167,8 +167,11 @@ export default class Cartoon {
}) })
} }
stopVideo(videoPlayer) {
videoPlayer.stop()
}
playVideo(videoPlayer, callback) { playVideo(videoPlayer, callback) {
console.log(videoPlayer)
if(videoPlayer && videoPlayer.isPlaying) { if(videoPlayer && videoPlayer.isPlaying) {
videoPlayer.stop() videoPlayer.stop()
} }
...@@ -347,13 +350,6 @@ class DragonBones { ...@@ -347,13 +350,6 @@ class DragonBones {
cc.loader.load(image, (error, texture) => { cc.loader.load(image, (error, texture) => {
cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => { cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => {
cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => { cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => {
// cc.loader.loadRes(image, (error, texture) => {
// console.log(error)
// cc.loader.loadRes(atlas, (error, atlasJson) => {
// console.log(error)
// cc.loader.loadRes(ske, (error, dragonBonesJson) => {
// console.log(error)
// console.log(atlasJson)
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = (atlasJson); atlas.atlasJson = (atlasJson);
atlas.texture = texture; atlas.texture = texture;
...@@ -396,14 +392,14 @@ class DragonBones { ...@@ -396,14 +392,14 @@ class DragonBones {
}) })
} }
if(callback) {
callback(this)
}
let sx = parentNode.width / animaNode.width; let sx = parentNode.width / animaNode.width;
let sy = parentNode.height / animaNode.height; let sy = parentNode.height / animaNode.height;
animaNode.setScale(Math.min(sx, sy)); animaNode.setScale(Math.min(sx, sy));
if(callback) {
callback(this)
}
}); });
}); });
}); });
...@@ -416,6 +412,10 @@ class DragonBones { ...@@ -416,6 +412,10 @@ class DragonBones {
} }
} }
stopDragonBones() {
this._animationLoaded.armature().animation.stop();
}
showDragonBones(times = 1, animaName, callBack) { showDragonBones(times = 1, animaName, callBack) {
let animaNameIndex = this._animationLoaded.animaNames.indexOf(animaName) let animaNameIndex = this._animationLoaded.animaNames.indexOf(animaName)
if (this._animationLoaded && this._animationLoaded.animaNames.length > 0) { if (this._animationLoaded && this._animationLoaded.animaNames.length > 0) {
......
...@@ -98,7 +98,11 @@ export default class GameLogic { ...@@ -98,7 +98,11 @@ export default class GameLogic {
} }
initBg() { initBg() {
console.log(this.g_formData.theme) const bgBubble = cc.find('Canvas/bgMain/bubble');
bgBubble.scale = this.g_systemOption.mapScaleMin;
// bgBubble.width = cc.winSize.width
// bgBubble.height = cc.winSize.height
const bgNode_A = cc.find('Canvas/bgMain/bg_A'); const bgNode_A = cc.find('Canvas/bgMain/bg_A');
// bgNode_A.scale = this.g_systemOption.mapScaleMin; // bgNode_A.scale = this.g_systemOption.mapScaleMin;
bgNode_A.width = cc.winSize.width bgNode_A.width = cc.winSize.width
...@@ -242,30 +246,43 @@ export default class GameLogic { ...@@ -242,30 +246,43 @@ export default class GameLogic {
} }
} }
stopCurrentPlaying() {
let rightDragon = this.g_cartoon.getCartoonElement("rightDragonContainer")
let videoContainer = this.g_cartoon.getCartoonElement("video_container_video")
let textContainer = this.g_cartoon.getCartoonElement("textDragonContainer")
textContainer.dragonBones.stopDragonBones()
rightDragon.dragonBones.stopDragonBones()
this.g_cartoon.stopVideo(videoContainer.node.getComponent(cc.VideoPlayer))
this.g_cartoon.stopAllAudio()
}
playCurrentQuestion() { playCurrentQuestion() {
const play = ()=>{ const play = ()=>{
let rightDragon = this.g_cartoon.getCartoonElement("rightDragonContainer") let rightDragon = this.g_cartoon.getCartoonElement("rightDragonContainer")
var container = this.g_cartoon.getCartoonElement("video_container_video") var container = this.g_cartoon.getCartoonElement("video_container_video")
this.g_cartoon.getCartoonElement("textDragonContainer").play() this.g_cartoon.getCartoonElement("textDragonContainer").play()
if(this.g_formData.dataArray[this.m_currentQuestion].text_audio_url) { if(this.g_formData.dataArray[this.m_currentQuestion].text_audio_url) {
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].text_audio_url) this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].text_audio_url)
} }
this.g_cartoon.playVideo(container.node.getComponent(cc.VideoPlayer), ()=>{ this.g_cartoon.playVideo(container.node.getComponent(cc.VideoPlayer), ()=>{
rightDragon.play() rightDragon.play()
console.log("ADV")
if(this.g_formData.dataArray[this.m_currentQuestion].right_audio_url) { if(this.g_formData.dataArray[this.m_currentQuestion].right_audio_url) {
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].right_audio_url) this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].right_audio_url)
} }
}) })
} }
if(this.m_firstEnter) { if(!this.g_formData.dataArray[this.m_currentQuestion].played) {
this.m_firstEnter = false; this.g_formData.dataArray[this.m_currentQuestion].played = true;
this.g_cartoon.playAudio("sm_join", () => { this.g_cartoon.playAudio("sm_join", () => {
this.stopCurrentPlaying();
play() play()
}) })
} else { } else {
this.stopCurrentPlaying();
play() play()
} }
...@@ -302,14 +319,20 @@ export default class GameLogic { ...@@ -302,14 +319,20 @@ export default class GameLogic {
} }
} }
textDragon.setDragonBones = (dragon) => { textDragon.setDragonBones = (dragon, callback) => {
if(dragon && dragon.texPngData.url && dragon.skeJsonData.url && dragon.texJsonData.url) { if(dragon && dragon.texPngData.url && dragon.skeJsonData.url && dragon.texJsonData.url) {
textDragon.dragonBones.setDragonBones(dragon, null, (handle)=>{ textDragon.dragonBones.setDragonBones(dragon, null, (handle)=>{
textDragon.dragonBonesLoaded = handle; textDragon.dragonBonesLoaded = handle;
if(callback) {
callback()
}
}) })
} else{ } else{
textDragon.dragonBones.deleteDragonBones() textDragon.dragonBones.deleteDragonBones()
textDragon.dragonBonesLoaded = null; textDragon.dragonBonesLoaded = null;
if(callback) {
callback()
}
} }
} }
...@@ -317,12 +340,12 @@ export default class GameLogic { ...@@ -317,12 +340,12 @@ export default class GameLogic {
rightDragon.node.opacity = 255; rightDragon.node.opacity = 255;
rightDragon.show = (callBack) => { rightDragon.show = (callBack) => {
if(rightDragon.node.opacity == 255) { if(rightDragon.node.opacity == 255) {
if(callBack) { if(callback) {
callback() callback()
} }
} else { } else {
this.g_cartoon.tweenChange(rightDragon.node, {opacity: 255}, 0.3, ()=>{ this.g_cartoon.tweenChange(rightDragon.node, {opacity: 255}, 0.3, ()=>{
if(callBack) { if(callback) {
callback() callback()
} }
}); });
...@@ -338,7 +361,7 @@ export default class GameLogic { ...@@ -338,7 +361,7 @@ export default class GameLogic {
} }
} }
rightDragon.setDragonBones = (dragon) => { rightDragon.setDragonBones = (dragon, callback) => {
if(dragon && dragon.texPngData.url && dragon.skeJsonData.url && dragon.texJsonData.url) { if(dragon && dragon.texPngData.url && dragon.skeJsonData.url && dragon.texJsonData.url) {
rightDragon.dragonBones.setDragonBones(dragon, null, (handle)=>{ rightDragon.dragonBones.setDragonBones(dragon, null, (handle)=>{
// let sx = 498 / handle._animationLoaded.node.width; // let sx = 498 / handle._animationLoaded.node.width;
...@@ -354,10 +377,16 @@ export default class GameLogic { ...@@ -354,10 +377,16 @@ export default class GameLogic {
// }, ()=>{ // }, ()=>{
// // handle.showDragonBones(); // // handle.showDragonBones();
// }) // })
if(callback) {
callback()
}
}) })
} else{ } else{
rightDragon.dragonBones.deleteDragonBones() rightDragon.dragonBones.deleteDragonBones()
rightDragon.dragonBonesLoaded = null; rightDragon.dragonBonesLoaded = null;
if(callback) {
callback()
}
} }
} }
} }
...@@ -380,22 +409,34 @@ export default class GameLogic { ...@@ -380,22 +409,34 @@ export default class GameLogic {
let textDragon = this.g_formData.dataArray[this.m_currentQuestion].textDragonBones let textDragon = this.g_formData.dataArray[this.m_currentQuestion].textDragonBones
let rightDragon = this.g_formData.dataArray[this.m_currentQuestion].rightDragonBones let rightDragon = this.g_formData.dataArray[this.m_currentQuestion].rightDragonBones
this.g_cartoon.getCartoonElement("textDragonContainer").setDragonBones(textDragon)
this.g_cartoon.getCartoonElement("rightDragonContainer").setDragonBones(rightDragon) let p1 = new Promise((resolve, reject) => {
this.g_cartoon.getCartoonElement("textDragonContainer").setDragonBones(textDragon, ()=>{
resolve()
})
})
let p2 = new Promise((resolve, reject) => {
this.g_cartoon.getCartoonElement("rightDragonContainer").setDragonBones(rightDragon, ()=>{
resolve()
})
})
let video = this.g_cartoon.getCartoonElement("video_container_video") let video = this.g_cartoon.getCartoonElement("video_container_video")
if(this.g_formData.dataArray[this.m_currentQuestion].video_url) { let p3 = new Promise((resolve, reject) => {
video.node.active = true; if(this.g_formData.dataArray[this.m_currentQuestion].video_url) {
this.g_cartoon.getVideo(this.g_formData.dataArray[this.m_currentQuestion].video_url).then((clip=>{ video.node.active = true;
video.node.getComponent(cc.VideoPlayer).clip = clip this.g_cartoon.getVideo(this.g_formData.dataArray[this.m_currentQuestion].video_url).then((clip=>{
this.playCurrentQuestion() video.node.getComponent(cc.VideoPlayer).clip = clip
})) resolve()
} else { }))
video.node.active = false; } else {
this.playCurrentQuestion() video.node.active = false;
} resolve()
}
})
return true; return Promise.all([p1, p2, p3])
} }
initBottomButtons() { initBottomButtons() {
...@@ -409,12 +450,15 @@ export default class GameLogic { ...@@ -409,12 +450,15 @@ export default class GameLogic {
} }
this.g_cartoon.playAudio("sm_btn"); this.g_cartoon.playAudio("sm_btn");
this.disableClick("btn_left") this.disableClick("btn_left")
this.stopCurrentPlaying();
jelly(btnLeft.node) jelly(btnLeft.node)
this.showMaskLayer(()=>{ this.showMaskLayer(()=>{
this.loadQuestion(false) this.loadQuestion(false).then(()=>{
this.hideMaskLayer(()=>{ this.hideMaskLayer(()=>{
this.enableClick("btn_left") this.playCurrentQuestion()
}) this.enableClick("btn_left")
})
})
}) })
}) })
...@@ -424,12 +468,15 @@ export default class GameLogic { ...@@ -424,12 +468,15 @@ export default class GameLogic {
} }
this.g_cartoon.playAudio("sm_btn"); this.g_cartoon.playAudio("sm_btn");
this.disableClick("btn_right") this.disableClick("btn_right")
this.stopCurrentPlaying();
jelly(btnRight.node) jelly(btnRight.node)
this.showMaskLayer(()=>{ this.showMaskLayer(()=>{
this.loadQuestion(true) this.loadQuestion(true).then(()=>{
this.hideMaskLayer(()=>{ this.hideMaskLayer(()=>{
this.enableClick("btn_right") this.playCurrentQuestion()
}) this.enableClick("btn_right")
})
})
}) })
}) })
......
This diff is collapsed.
This diff is collapsed.
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