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

Bug fix

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