Commit ce0e330e authored by 李维's avatar 李维

翻页时停止酷猫说话

parent 05c5c0b1
......@@ -183,6 +183,10 @@ cc.Class({
},
onTouchLeft() {
return new Promise((resolve, reject) => {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
if (this.verletRender) {
return resolve('');
}
......@@ -195,6 +199,7 @@ cc.Class({
GameData.isPlaying = 1;
let page = this.pageList[GameData.pageIndex];
let itemPage = page.getComponent('ItemPage');
this.stopAllAudio();
itemPage.playAudio();
itemPage.playSpine().then(() => {
let nextPage = this.pageList[GameData.pageIndex + 1];
......@@ -209,6 +214,10 @@ cc.Class({
},
onTouchRight() {
return new Promise((resolve, reject) => {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
if (this.verletRender) {
return resolve('');
}
......@@ -226,6 +235,7 @@ cc.Class({
}
GameData.isPlaying = 2;
let itemPage = page.getComponent('ItemPage');
this.stopAllAudio();
itemPage.playAudio();
itemPage.playSpine().then(() => {
if (this.pageList.length - GameData.pageIndex <= 2) {
......@@ -407,6 +417,7 @@ cc.Class({
if (this.isTruning) {
return false;
}
this.stopAllAudio();
if (GameData.isPlaying == 1) {
this.stopLeft();
// return false;
......@@ -425,6 +436,7 @@ cc.Class({
if (this.isTruning) {
return false;
}
this.stopAllAudio();
if (GameData.isPlaying) {
this.stopLeft();
this.stopRight();
......@@ -437,7 +449,6 @@ cc.Class({
return true;
},
catSpeakStart(cb) {
const cat = cc.find('Canvas/mao');
playDragonBoneAnimation(cat, 'begin', 0);
......@@ -465,7 +476,6 @@ cc.Class({
});
},
catSpeakEnd(cb) {
const cat = cc.find('Canvas/mao');
playDragonBoneAnimation(cat, 'finish', 0);
......@@ -478,10 +488,15 @@ cc.Class({
},
onTouchCat() {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
this.catSpeakWait(() => {
console.log("猫说话")
});
},
catSpeakWait(cb) {
const cat = cc.find('Canvas/mao');
playDragonBoneAnimation(cat, 'begin', -1);
......@@ -491,6 +506,13 @@ cc.Class({
});
},
// 停止所有音频
stopAllAudio() {
const cat = cc.find('Canvas/mao');
cc.audioEngine.stopAll();
playDragonBoneAnimation(cat, 'normal', -1);
},
currentPlayedAudioId: null,
stopCurrentPlayedAudio() {
if (this.currentPlayedAudioId !== null) {
......@@ -498,6 +520,7 @@ cc.Class({
this.currentPlayedAudioId = null;
}
},
playEffect(name, cb) {
this.stopCurrentPlayedAudio();
const audioNode = cc.find(`audios/${name}`);
......@@ -517,6 +540,7 @@ cc.Class({
this.playAudioQuestion();
})
},
playAudioPage(isBtn, cb) {
GameData.audioCount++;
let url = this.data.questionList[GameData.questionIndex].pageAudio;
......
......@@ -39,6 +39,8 @@ cc.Class({
btnRight: cc.Node,
// verletRender: VerletRender,
capture: require('capture_to_web'),
},
// 生命周期 onLoad
......@@ -181,6 +183,10 @@ cc.Class({
},
onTouchLeft() {
return new Promise((resolve, reject) => {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
if (this.verletRender) {
return resolve('');
}
......@@ -193,6 +199,7 @@ cc.Class({
GameData.isPlaying = 1;
let page = this.pageList[GameData.pageIndex];
let itemPage = page.getComponent('ItemPage');
this.stopAllAudio();
itemPage.playAudio();
itemPage.playSpine().then(() => {
let nextPage = this.pageList[GameData.pageIndex + 1];
......@@ -207,6 +214,10 @@ cc.Class({
},
onTouchRight() {
return new Promise((resolve, reject) => {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
if (this.verletRender) {
return resolve('');
}
......@@ -224,6 +235,7 @@ cc.Class({
}
GameData.isPlaying = 2;
let itemPage = page.getComponent('ItemPage');
this.stopAllAudio();
itemPage.playAudio();
itemPage.playSpine().then(() => {
if (this.pageList.length - GameData.pageIndex <= 2) {
......@@ -405,6 +417,7 @@ cc.Class({
if (this.isTruning) {
return false;
}
this.stopAllAudio();
if (GameData.isPlaying == 1) {
this.stopLeft();
// return false;
......@@ -423,6 +436,7 @@ cc.Class({
if (this.isTruning) {
return false;
}
this.stopAllAudio();
if (GameData.isPlaying) {
this.stopLeft();
this.stopRight();
......@@ -476,6 +490,10 @@ cc.Class({
},
onTouchCat() {
if (!this.inited) return resolve('');
if (this.isTruning) {
return resolve('');
}
this.catSpeakWait(() => {
console.log("猫说话")
});
......@@ -489,6 +507,13 @@ cc.Class({
});
},
// 停止所有音频
stopAllAudio() {
const cat = cc.find('Canvas/mao');
cc.audioEngine.stopAll();
playDragonBoneAnimation(cat, 'normal', -1);
},
currentPlayedAudioId: null,
stopCurrentPlayedAudio() {
if (this.currentPlayedAudioId !== null) {
......
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