Commit e9dd4b30 authored by Tt's avatar Tt

hy01卡死测试

parent bfd1bb43
...@@ -16,6 +16,9 @@ export default class LayerBack extends cc.Component { ...@@ -16,6 +16,9 @@ export default class LayerBack extends cc.Component {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
} }
protected onDestroy(): void {
this.unscheduleAllCallbacks();
}
private label_title: cc.Node; private label_title: cc.Node;
......
...@@ -13,6 +13,9 @@ export default class ImgVoice extends cc.Component { ...@@ -13,6 +13,9 @@ export default class ImgVoice extends cc.Component {
this.initView(); this.initView();
this.initEvent(); this.initEvent();
} }
protected onDestroy(): void {
this.unscheduleAllCallbacks();
}
initView() { initView() {
this.img_npc_voice = this.node; this.img_npc_voice = this.node;
} }
...@@ -32,6 +35,7 @@ export default class ImgVoice extends cc.Component { ...@@ -32,6 +35,7 @@ export default class ImgVoice extends cc.Component {
} }
playVoiceRunning() { playVoiceRunning() {
this.playVoiceCount++; this.playVoiceCount++;
if (!this.img_npc_voice) return;
let p1 = this.img_npc_voice.getChildByName('p1') let p1 = this.img_npc_voice.getChildByName('p1')
let p2 = this.img_npc_voice.getChildByName('p2') let p2 = this.img_npc_voice.getChildByName('p2')
let p3 = this.img_npc_voice.getChildByName('p3') let p3 = this.img_npc_voice.getChildByName('p3')
......
...@@ -26,6 +26,9 @@ export default class LayerRecord extends cc.Component { ...@@ -26,6 +26,9 @@ export default class LayerRecord extends cc.Component {
this.initEvent(); this.initEvent();
this.showVoiceWhite(); this.showVoiceWhite();
} }
protected onDestroy(): void {
this.unscheduleAllCallbacks();
}
private letter: string; private letter: string;
private targetTime: number; private targetTime: number;
private recordAudio: string; private recordAudio: string;
...@@ -121,6 +124,7 @@ export default class LayerRecord extends cc.Component { ...@@ -121,6 +124,7 @@ export default class LayerRecord extends cc.Component {
playVoiceRunning() { playVoiceRunning() {
this.playVoiceCount++; this.playVoiceCount++;
let btn_play = pg.view.find(this.layout_record, 'btn_play'); let btn_play = pg.view.find(this.layout_record, 'btn_play');
if (!btn_play) return;
let p0 = btn_play.getChildByName('p0') let p0 = btn_play.getChildByName('p0')
let p1 = btn_play.getChildByName('p1') let p1 = btn_play.getChildByName('p1')
let p2 = btn_play.getChildByName('p2') let p2 = btn_play.getChildByName('p2')
......
...@@ -45,6 +45,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -45,6 +45,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
pg.event.emit('npc_layer_back_init', this.data) pg.event.emit('npc_layer_back_init', this.data)
} }
protected onDestroy(): void {
pg.event.clear();
}
_cantouch = null; _cantouch = null;
private list: Array<{ type, text, right, imgage, duration, content, audio }>; private list: Array<{ type, text, right, imgage, duration, content, audio }>;
...@@ -52,6 +55,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -52,6 +55,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private score: number; private score: number;
private scoreList: Array<number>; private scoreList: Array<number>;
private tempCount: number; private tempCount: number;
private maxCurrent: number;
initData() { initData() {
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
this._cantouch = true; this._cantouch = true;
...@@ -61,6 +65,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -61,6 +65,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.recordFlag = data.recordFlag; this.recordFlag = data.recordFlag;
this.list = data.questions[0].options; this.list = data.questions[0].options;
this.scoreList = this.list.map(() => 3); this.scoreList = this.list.map(() => 3);
this.maxCurrent = 0;
this.layers = []; this.layers = [];
} }
...@@ -91,9 +96,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -91,9 +96,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(move.toString()); console.log(move.toString());
if (move.x < -10) { if (move.x < -10) {
this.touchForbid = true; this.touchForbid = true;
console.log("lastPage")
this.lastPage(); this.lastPage();
} else if (move.x > 10) { } else if (move.x > 10) {
this.touchForbid = true; this.touchForbid = true;
console.log("nextPage")
this.nextPage(); this.nextPage();
} }
} }
...@@ -102,7 +109,15 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -102,7 +109,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.preLayer(); this.preLayer();
} }
nextPage() { nextPage() {
this.nextLayer(); if (this.recordFlag) {
if (this.count + 1 <= this.maxCurrent) {
this.nextLayer();
} else {
this.touchForbid = false;
}
} else {
this.nextLayer();
}
} }
resetView() { resetView() {
this.layer_game.removeAllChildren(); this.layer_game.removeAllChildren();
...@@ -172,6 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -172,6 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.audio.playAudioByUrl(this.CurrentData.audio, () => { pg.audio.playAudioByUrl(this.CurrentData.audio, () => {
this.currentAudioId = null; this.currentAudioId = null;
com.playVoiceEnd(); com.playVoiceEnd();
this.touchForbid = false;
pg.event.emit('layer_record_open', { pg.event.emit('layer_record_open', {
letter: this.CurrentData.content, letter: this.CurrentData.content,
targetTime: this.CurrentData.duration, targetTime: this.CurrentData.duration,
...@@ -195,9 +211,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -195,9 +211,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.audio.playAudioByUrl(this.CurrentData.audio, () => { pg.audio.playAudioByUrl(this.CurrentData.audio, () => {
this.currentAudioId = null; this.currentAudioId = null;
com.playVoiceEnd(); com.playVoiceEnd();
this.touchForbid = true;
this.touchForbid = false; this.scheduleOnce(() => {
this.nextLayer(); this.touchForbid = false;
this.nextLayer();
}, 3)// 动画过来播放之后等待三秒
// pg.event.once('layer_coin_show_coin_end', () => { // pg.event.once('layer_coin_show_coin_end', () => {
// this.touchForbid = false; // this.touchForbid = false;
// this.nextLayer(); // this.nextLayer();
...@@ -249,7 +268,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -249,7 +268,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.once('layer_coin_show_coin_end', () => { pg.event.once('layer_coin_show_coin_end', () => {
this.nextLayer(); this.nextLayer();
}) // 动画回调 }) // 动画回调
pg.event.emit('layer_coin_show_coin', 1) //1 2 3硬币数量 pg.event.emit('layer_coin_show_coin', 2) //1 2 3硬币数量
}) })
pg.event.emit('layer_right_show_good') pg.event.emit('layer_right_show_good')
} else { } else {
...@@ -312,6 +331,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -312,6 +331,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.scheduleOnce(() => { this.scheduleOnce(() => {
this.touchForbid = false; this.touchForbid = false;
this.count++; this.count++;
this.maxCurrent = Math.max(this.maxCurrent, this.count);
this.startPlay(); this.startPlay();
}, 1) }, 1)
} }
......
...@@ -391,6 +391,7 @@ let pg = { ...@@ -391,6 +391,7 @@ let pg = {
let node = item.node ? item.node : item; let node = item.node ? item.node : item;
if (!node) return; if (!node) return;
let component = node.getComponent(cc.Label);//组件功能 非node的功能 let component = node.getComponent(cc.Label);//组件功能 非node的功能
component.cacheMode = cc.Label.CacheMode.CHAR;
component.string = text; component.string = text;
return true; return true;
}, },
......
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