Commit c255575c authored by limingzhe's avatar limingzhe

fix: 闪屏处理

parents 0071c42e dc5babd8
{ {"ver":"1.1.2","uuid":"810c015d-857f-44be-aa35-fcda8b54edb3","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2", \ No newline at end of file
"uuid": "810c015d-857f-44be-aa35-fcda8b54edb3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
...@@ -356,19 +356,19 @@ cc.Class({ ...@@ -356,19 +356,19 @@ cc.Class({
} }
// window.dispatchEvent(new CustomEvent('resize'), true) // window.dispatchEvent(new CustomEvent('resize'), true)
// window.dispatchEvent(new cc.Event.EventCustom('resize', true)) // window.dispatchEvent(new cc.Event.EventCustom('resize', true))
}); }, this);
cc.director.on('GAME_VIEW_DISPLAYED', () => { cc.director.on('GAME_VIEW_DISPLAYED', function() {
// this.karaoke.prepare(); // this.karaoke.prepare();
}); }, this);
window.gg =this window.gg =this
this.btnGroup.children.forEach(button => { this.btnGroup.children.forEach(button => {
button.actionStatus = this.BUTTON_STATUS.IDLE; button.actionStatus = this.BUTTON_STATUS.IDLE;
button.on(cc.Node.EventType.TOUCH_START, (event) => { button.on(cc.Node.EventType.TOUCH_START, function(event) {
const btn = event.currentTarget; const btn = event.currentTarget;
window.bb = btn; window.bb = btn;
this.buttonGroupChange(btn) this.buttonGroupChange(btn)
// cc.log("This is a callback after the trigger event", event); // cc.log("This is a callback after the trigger event", event);
}) }, this)
}); });
; ;
}, },
......
...@@ -14,6 +14,26 @@ var DISPLAY_MODE = cc.Enum({ ...@@ -14,6 +14,26 @@ var DISPLAY_MODE = cc.Enum({
const LINE_BEAKER = '<br/>'; // '\n' const LINE_BEAKER = '<br/>'; // '\n'
const SPACE = ' '; const SPACE = ' ';
class MyAudioSource {
play(){
this.audId = cc.audioEngine.play(this.clip, false, 1);
}
stop(){
cc.audioEngine.stop(this.audId);
}
pause(){
cc.audioEngine.pause(this.audId);
}
resume(){
cc.audioEngine.resume(this.audId);
}
getCurrentTime () {
cc.audioEngine.getCurrentTime(this.audId);
}
setCurrentTime (sec) {
cc.audioEngine.setCurrentTime(this.audId, sec);
}
}
/** /**
* 1.添加空节点,设置节点大小,拖入该脚本 * 1.添加空节点,设置节点大小,拖入该脚本
...@@ -148,7 +168,7 @@ cc.Class({ ...@@ -148,7 +168,7 @@ cc.Class({
window['kk'] = this; window['kk'] = this;
cc.director.on('STOP_ALL_AUDIO_sb_karaoke_cocos', () => { cc.director.on('STOP_ALL_AUDIO_sb_karaoke_cocos', () => {
this.pause(); this.pause();
}); }, this);
}, },
setPlayInteractivateMode(mode) { setPlayInteractivateMode(mode) {
...@@ -498,7 +518,7 @@ cc.Class({ ...@@ -498,7 +518,7 @@ cc.Class({
// this._lrcNextLineTime = this._lrcData[this._lrcLineIndex] ? this._lrcData[this._lrcLineIndex].time : 0; // this._lrcNextLineTime = this._lrcData[this._lrcLineIndex] ? this._lrcData[this._lrcLineIndex].time : 0;
// return this._remainContent.shift(); // return this._remainContent.shift();
// } // }
if (!time) { if (!time || time < 0) {
time = 0; time = 0;
} }
let idx = 0; let idx = 0;
...@@ -592,12 +612,12 @@ cc.Class({ ...@@ -592,12 +612,12 @@ cc.Class({
let endIndex = nextLineObj.index; let endIndex = nextLineObj.index;
while(line = this._lrcData[endIndex]) { while(line = this._lrcData[endIndex]) {
if (line.newLine || index === 0 ) { if (line.newLine || index === 0 ) {
return line.time return line.time > 0 ? line.time : 0
} }
endIndex -= 1; endIndex -= 1;
} }
return { return {
time: line.time, time: line.time > 0 ? line.time : 0,
index: lineObj.index index: lineObj.index
}; };
}, },
...@@ -646,11 +666,11 @@ cc.Class({ ...@@ -646,11 +666,11 @@ cc.Class({
// }) // })
// console.log(n._id,ss,breakIndex,tm, idx, n.x,n.y); // console.log(n._id,ss,breakIndex,tm, idx, n.x,n.y);
n.off(cc.Node.EventType.TOUCH_START) n.off(cc.Node.EventType.TOUCH_START)
n.on(cc.Node.EventType.TOUCH_START, () => { n.on(cc.Node.EventType.TOUCH_START, function() {
console.log(n._id,ss,breakIndex,tm, idx, n.x,n.y,this.richText.node.children.indexOf(n) ); console.log(n._id,ss,breakIndex,tm, idx, n.x,n.y,this.richText.node.children.indexOf(n) );
this.calcSentenceRichText.string = this.sentenceContent[tm]; this.calcSentenceRichText.string = this.sentenceContent[tm];
this.playByTime(tm); this.playByTime(tm);
}); }, this);
const s = n.getComponent(cc.Label).string; const s = n.getComponent(cc.Label).string;
this.findSentenceIndexByWords(s, sentenceIndexObj); this.findSentenceIndexByWords(s, sentenceIndexObj);
} }
...@@ -845,6 +865,9 @@ cc.Class({ ...@@ -845,6 +865,9 @@ cc.Class({
if (overrideTime) { if (overrideTime) {
startTime = overrideTime; startTime = overrideTime;
} }
if (startTime < 0) {
startTime = 0;
}
this.playByTimePhaseStartTime = startTime; this.playByTimePhaseStartTime = startTime;
this.playByTimePhaseEndTime = endTime; this.playByTimePhaseEndTime = endTime;
this.playByTimePhaseStep = step; this.playByTimePhaseStep = step;
...@@ -967,6 +990,9 @@ cc.Class({ ...@@ -967,6 +990,9 @@ cc.Class({
this.resetLRC(); this.resetLRC();
}, },
seek(time) { seek(time) {
if (time < 0) {
time = 0
}
const adSrc = this.getCurrentPlayingSource(); const adSrc = this.getCurrentPlayingSource();
adSrc.setCurrentTime(time); adSrc.setCurrentTime(time);
}, },
...@@ -994,18 +1020,39 @@ cc.Class({ ...@@ -994,18 +1020,39 @@ cc.Class({
}, },
onDestroy() { onDestroy() {
console.log('onDestroy onDestroy');
// audioEngine.uncache(this.audioUrl); // audioEngine.uncache(this.audioUrl);
if (this._currentAudioId) { if (this._currentAudioId) {
audioEngine.stop(this._currentAudioId); audioEngine.stop(this._currentAudioId);
} }
if (this._audioSource) {
console.log('this._audioSource: ', this._audioSource); if (this._audioSource && this._audioSource.audio) {
this._audioSource.audio.stop()
this._audioSource.stop(); this._audioSource.stop();
// this._audioSource.audio.destroy();
this._audioSource.audio = null;
// this._audioSource._destruct();
} }
if (this._audioACSource) { if (this._audioACSource && this._audioACSource.audio) {
console.log('this._audioACSource: ', this._audioACSource); this._audioACSource.audio.stop()
this._audioACSource.stop(); this._audioACSource.stop();
// this._audioACSource.audio.destroy();
this._audioACSource.audio = null;
// this._audioSource._destruct();
} }
// if (this._audioSource && this._audioSource.isValid) {
// this._audioSource.destroy();
// // this._audioSource._destruct();
// }
// if (this._audioACSource && this._audioACSource.isValid) {
// this._audioACSource.destroy();
// // this._audioACSource._destruct();
// }
// this._audioSource = null;
// this._audioACSource = null;
// this._destruct();
} }
}); });
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
"__id__": 3 "__id__": 3
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 2,
"_target": null, "_target": null,
"_alignFlags": 45, "_alignFlags": 45,
"_left": 0, "_left": 0,
...@@ -504,7 +504,7 @@ ...@@ -504,7 +504,7 @@
"__id__": 9 "__id__": 9
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 2,
"_target": null, "_target": null,
"_alignFlags": 44, "_alignFlags": 44,
"_left": 0, "_left": 0,
...@@ -2263,7 +2263,7 @@ ...@@ -2263,7 +2263,7 @@
"__id__": 52 "__id__": 52
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 2,
"_target": null, "_target": null,
"_alignFlags": 45, "_alignFlags": 45,
"_left": 0, "_left": 0,
...@@ -5378,7 +5378,7 @@ ...@@ -5378,7 +5378,7 @@
"__id__": 2 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 2,
"_target": null, "_target": null,
"_alignFlags": 45, "_alignFlags": 45,
"_left": 0, "_left": 0,
......
...@@ -85,6 +85,18 @@ cc.Class({ ...@@ -85,6 +85,18 @@ cc.Class({
}, },
getData(func) { getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'scene');
return;
}
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData(func);
return;
}
func(this.getDefaultData()); func(this.getDefaultData());
}, },
...@@ -470,7 +482,7 @@ cc.Class({ ...@@ -470,7 +482,7 @@ cc.Class({
} }
rectNode.addComponent(cc.Button); rectNode.addComponent(cc.Button);
rectNode.on('click', () => { rectNode.on('click', function(){
if (rectNode.isClicked) { if (rectNode.isClicked) {
// return; // return;
} }
...@@ -486,7 +498,7 @@ cc.Class({ ...@@ -486,7 +498,7 @@ cc.Class({
if (animationNames.length > 0) { if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1); dragonDisplay.playAnimation(animationNames[0], 1);
} }
}); }, this);
} }
}); });
...@@ -534,12 +546,12 @@ cc.Class({ ...@@ -534,12 +546,12 @@ cc.Class({
}); });
picNode.addComponent(cc.Button); picNode.addComponent(cc.Button);
picNode.on('click', () => { picNode.on('click', function() {
if (picNode.audioClip) { if (picNode.audioClip) {
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(picNode.audioClip, false, 0.8); cc.audioEngine.playEffect(picNode.audioClip, false, 0.8);
} }
}); }, this);
}, },
......
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