Scene.js 15.3 KB
Newer Older
asdf's avatar
.  
asdf committed
1
const saveKey = "DataKey_Cocos_FT11";
asdf's avatar
.  
asdf committed
2
const BaseUI = require('BaseUI');
Li Mingzhe's avatar
Li Mingzhe committed
3 4
cc.Class({

asdf's avatar
.  
asdf committed
5
	extends: BaseUI,
Li Mingzhe's avatar
Li Mingzhe committed
6 7

	properties: {
asdf's avatar
asdf committed
8
		audEnter: cc.AudioClip,
asdf's avatar
asdf committed
9 10 11
		audMove: cc.AudioClip,
		audMerge: cc.AudioClip,
		audClick: cc.AudioClip,
asdf's avatar
.  
asdf committed
12 13
		pfbItemAnswer: cc.Prefab,
		pfbItemQuestion: cc.Prefab,
asdf's avatar
asdf committed
14
		layerOver: cc.Prefab,
Li Mingzhe's avatar
Li Mingzhe committed
15 16 17 18
	},

	// 生命周期 onLoad
	onLoad() {
asdf's avatar
.  
asdf committed
19
		this._super();
asdf's avatar
asdf committed
20
		this.initNodes();
Li Mingzhe's avatar
Li Mingzhe committed
21 22
		this.initSceneData();
		this.initSize();
asdf's avatar
asdf committed
23 24 25 26 27 28 29 30 31 32 33
	},
	initNodes() {

	},

	onEnable() {

	},

	onDisable() {

Li Mingzhe's avatar
Li Mingzhe committed
34 35
	},

asdf's avatar
.  
asdf committed
36
	_resList: null,
Li Mingzhe's avatar
Li Mingzhe committed
37
	initSceneData() {
asdf's avatar
.  
asdf committed
38
		this._resList = [];
asdf's avatar
asdf committed
39
		window.GameData = {};
Li Mingzhe's avatar
Li Mingzhe committed
40 41 42 43 44 45 46 47 48 49 50 51 52
	},

	_designSize: null,  // 设计分辨率
	_frameSize: null,  // 屏幕分辨率
	_mapScaleMin: null,  // 场景中常用缩放(取大值)
	_mapScaleMax: null,  // 场景中常用缩放(取小值)
	_cocosScale: null,  // cocos 自缩放 (较少用到)
	initSize() {

	},


	// 生命周期 start
范雪寒's avatar
范雪寒 committed
53
	start() {
asdf's avatar
asdf committed
54
		this.getData((data) => {
Li Mingzhe's avatar
Li Mingzhe committed
55
			console.log('data:', data);
asdf's avatar
asdf committed
56 57 58 59
			this.data = data;
			if (data) {
				this.preloadItem()
			}
Li Mingzhe's avatar
Li Mingzhe committed
60 61 62 63
		})
	},

	getData(cb) {
asdf's avatar
asdf committed
64 65 66 67 68 69 70 71 72 73
		// 获取数据
		if (window.courseware) {
			const getData = window.courseware.getData;
			getData((data) => {
				data = data || this.getDefaultData();
				cb && cb(data);
			}, saveKey);
		} else {
			cb && cb(this.getDefaultData());
		}
Li Mingzhe's avatar
Li Mingzhe committed
74 75 76
	},

	getDefaultData() {
77
		let dataJson = '{"questionList":[{"questionAudio":"http://staging-teach.cdn.ireadabc.com/d2a9d8815d0370dc3b9aa18987dee584.mp3","questionText":"标题1","optionList":[{"text":"题干文本1","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/48b884b3c7b3a717f6e4b055f490a1f1.json","name":"walkingfish_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/608b2c5f85297f0b7930325733b7bea9.json","name":"walkingfish_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/ecfd66f932659635f5b66642378d826b.png","name":"walkingfish_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/4e267b9c0b58ebb153bfc0ae520cb7fe.mp3"},{"text":"题干文本2","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/90fd9908a33a3d087ac53e6f7d794c18.mp3"},{"text":"题干文本3","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/7ee85feaee06931e85cd0dd4ee64eeb1.mp3"},{"text":"题干文本45","optionDragonBone":{"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/248e684b0680d5ae39bacab7242b49f0.mp3"}]},{"questionAudio":"http://staging-teach.cdn.ireadabc.com/1d192b1cb2f2b1864ca55e903711081a.mp3","questionText":"","optionList":[{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/d2a9d8815d0370dc3b9aa18987dee584.mp3"},{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/4e267b9c0b58ebb153bfc0ae520cb7fe.mp3"},{"text":"题干文本","optionDragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"},"skeJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/efbe7f9b1ab7d7bc90ff13ac730882cc.json","name":"NewProject_2_ske.json"},"texJsonData2":{"url":"http://staging-teach.cdn.ireadabc.com/adb8e6c461753848a4650c74dc21c522.json","name":"NewProject_2_tex.json"},"texPngData2":{"url":"http://staging-teach.cdn.ireadabc.com/b132de0ee0425657eb64ed0b4f5f70a8.png","name":"NewProject_2_tex.png"}},"optionAudio":"http://staging-teach.cdn.ireadabc.com/90fd9908a33a3d087ac53e6f7d794c18.mp3"}]}]}';
asdf's avatar
asdf committed
78
		let data = JSON.parse(dataJson);
Li Mingzhe's avatar
Li Mingzhe committed
79 80
		return data;
	},
范雪寒's avatar
范雪寒 committed
81

Li Mingzhe's avatar
Li Mingzhe committed
82
	preloadItem() {
asdf's avatar
.  
asdf committed
83
		this.addPreloadItem();
Li Mingzhe's avatar
Li Mingzhe committed
84 85 86
		this.preload();
	},

asdf's avatar
.  
asdf committed
87 88 89 90 91 92 93 94 95 96 97
	addPreloadItem() {
		for (let i = 0; i < this.data.questionList.length; i++) {
			this._resList.push({ url: this.data.questionList[i].questionAudio });
			for (let j = 0; j < this.data.questionList[i].optionList.length; j++) {
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionAudio });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.skeJsonData.url });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texJsonData.url });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texPngData.url });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.skeJsonData2.url });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texJsonData2.url });
				this._resList.push({ url: this.data.questionList[i].optionList[j].optionDragonBone.texPngData2.url });
asdf's avatar
asdf committed
98 99
			}
		}
Li Mingzhe's avatar
Li Mingzhe committed
100 101 102
	},

	preload() {
asdf's avatar
.  
asdf committed
103
		cc.assetManager.loadAny(this._resList, null, null, (err, data) => {
Li Mingzhe's avatar
Li Mingzhe committed
104 105 106 107
			this.loadEnd();
			if (window && window["air"]) {
				window["air"].hideAirClassLoading();
			}
范雪寒's avatar
范雪寒 committed
108

Li Mingzhe's avatar
Li Mingzhe committed
109 110 111 112 113 114
			cc.debug.setDisplayStats(false);
		});
	},


	loadEnd() {
asdf's avatar
asdf committed
115
		GameData.questionIndex = 0;
Li Mingzhe's avatar
Li Mingzhe committed
116
		this.initData();
asdf's avatar
asdf committed
117

asdf's avatar
.  
asdf committed
118
		this.startGame();
Li Mingzhe's avatar
Li Mingzhe committed
119 120 121 122
	},

	initData() {
		// 所有全局变量 默认都是null 
123 124
		GameData.audioCount = 0;

asdf's avatar
asdf committed
125 126 127 128 129
		let optionList = this.data.questionList[GameData.questionIndex].optionList;
		this.optionList = [];
		for (let i = 0; i < optionList.length; i++) {
			this.optionList[i] = i;
		}
130
		GameData.isMoving = false;
asdf's avatar
.  
asdf committed
131
		this.initQuestionAndAnswer();
asdf's avatar
.  
asdf committed
132
		this.initTitle();
asdf's avatar
asdf committed
133
		this.updateBtnStatus();
asdf's avatar
asdf committed
134 135
	},

asdf's avatar
.  
asdf committed
136 137
	startGame() {
		this.playAudioEntrer();
Li Mingzhe's avatar
Li Mingzhe committed
138
	},
范雪寒's avatar
范雪寒 committed
139

asdf's avatar
.  
asdf committed
140 141 142 143 144 145 146 147 148
	initTitle() {
		let label = this.nodeDict.labTitle.getComponent(cc.Label);
		label.string = this.data.questionList[GameData.questionIndex].questionText;
		label._forceUpdateRenderData();
		if (this.nodeDict.labTitle.width > 567) {
			this.nodeDict.labTitle.scale = 567 / this.nodeDict.labTitle.width
		}
	},

asdf's avatar
.  
asdf committed
149 150 151
	// 初始化题干以及选项
	initQuestionAndAnswer() {
		let optionList = this.data.questionList[GameData.questionIndex].optionList;
asdf's avatar
asdf committed
152 153 154 155
		let answerIndexs = [1, 2, 3];
		if (optionList.length == 4) {
			answerIndexs = [1, 2, 3, 4];
		}
asdf's avatar
.  
asdf committed
156 157 158
		for (let i = 0; i < optionList.length; i++) {
			let question = cc.instantiate(this.pfbItemQuestion);
			question.parent = this.nodeDict.nodQuestionParent;
asdf's avatar
asdf committed
159 160 161 162
			question.x = this.getItemX(optionList, i);
			let ItemQuestion = question.getComponent('ItemQuestion');
			ItemQuestion.setInfo(optionList[i], i, this);
			ItemQuestion.setGray();
Li Mingzhe's avatar
Li Mingzhe committed
163

asdf's avatar
.  
asdf committed
164 165
			let answer = cc.instantiate(this.pfbItemAnswer);
			answer.parent = this.nodeDict.nodAnswerParent;
asdf's avatar
asdf committed
166 167 168 169 170

			let index = Math.floor(Math.random() * answerIndexs.length)
			answer.x = this.getItemX(optionList, answerIndexs[index] - 1);
			answerIndexs.splice(index, 1);

asdf's avatar
asdf committed
171
			answer.getComponent('ItemAnswer').setInfo(optionList[i], i, this);
asdf's avatar
asdf committed
172 173 174 175 176 177 178 179 180
		}
	},
	getItemX(optionList, index) {
		let itemWidth = 300;
		let space = 10;
		let x = index * (itemWidth + space) - 1.5 * (itemWidth + space);
		if (optionList.length == 3) {
			space = 56;
			x = index * (itemWidth + space) - 1 * (itemWidth + space);
Li Mingzhe's avatar
Li Mingzhe committed
181
		}
asdf's avatar
asdf committed
182
		return x;
asdf's avatar
asdf committed
183
	},
Li Mingzhe's avatar
Li Mingzhe committed
184

asdf's avatar
asdf committed
185

asdf's avatar
asdf committed
186
	playAudioEntrer() {
asdf's avatar
asdf committed
187
		GameData.audioCount++;
asdf's avatar
asdf committed
188
		let id = cc.audioEngine.play(this.audEnter, false, 1);
asdf's avatar
.  
asdf committed
189
		cc.audioEngine.setFinishCallback(id, () => {
asdf's avatar
asdf committed
190
			GameData.audioCount--;
asdf's avatar
asdf committed
191 192 193
			this.playAudioQuestion();
		})
	},
Li Mingzhe's avatar
Li Mingzhe committed
194

asdf's avatar
asdf committed
195
	playAudioQuestion(isBtn) {
asdf's avatar
asdf committed
196
		GameData.audioCount++;
asdf's avatar
.  
asdf committed
197 198
		let url = this.data.questionList[GameData.questionIndex].questionAudio;
		// url = 'http://127.0.0.1/iamflying.mp3';
asdf's avatar
asdf committed
199 200 201
		cc.assetManager.loadRemote(url, null, (err, clip) => {
			if (err) {
				console.log(err)
asdf's avatar
.  
asdf committed
202
				this.showRandomQuestion();
Li Mingzhe's avatar
Li Mingzhe committed
203 204
				return;
			}
asdf's avatar
asdf committed
205
			let id = cc.audioEngine.play(clip, false, 1);
asdf's avatar
.  
asdf committed
206
			cc.audioEngine.setFinishCallback(id, () => {
asdf's avatar
asdf committed
207
				GameData.audioCount--;
asdf's avatar
.  
asdf committed
208
				if (!isBtn) {
asdf's avatar
asdf committed
209 210
					this.showRandomQuestion();
				}
asdf's avatar
.  
asdf committed
211
			})
asdf's avatar
asdf committed
212
		});
Li Mingzhe's avatar
Li Mingzhe committed
213
	},
asdf's avatar
asdf committed
214
	playAudioMove() {
asdf's avatar
asdf committed
215
		GameData.audioCount++;
asdf's avatar
asdf committed
216 217
		let id = cc.audioEngine.play(this.audMove, false, 1);
		cc.audioEngine.setFinishCallback(id, () => {
asdf's avatar
asdf committed
218
			GameData.audioCount--;
asdf's avatar
asdf committed
219 220 221
		})
	},
	playAudioMerge() {
asdf's avatar
asdf committed
222
		GameData.audioCount++;
asdf's avatar
asdf committed
223 224
		let id = cc.audioEngine.play(this.audMerge, false, 1);
		cc.audioEngine.setFinishCallback(id, () => {
asdf's avatar
asdf committed
225
			GameData.audioCount--;
asdf's avatar
asdf committed
226 227
		})
	},
Li Mingzhe's avatar
Li Mingzhe committed
228

asdf's avatar
asdf committed
229
	// 随机亮起一个题干
asdf's avatar
.  
asdf committed
230
	showRandomQuestion() {
asdf's avatar
asdf committed
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
		GameData.currOptionIndex = this.optionList[Math.floor(Math.random() * this.optionList.length)]
		let question = this.nodeDict.nodQuestionParent.children[GameData.currOptionIndex];
		let ItemQuestion = question.getComponent('ItemQuestion');
		ItemQuestion.setNormal();
		ItemQuestion.showQipao();
		ItemQuestion.playAudioOption();
	},

	showNext(index) {
		for (let i = 0; i < this.optionList.length; i++) {
			if (this.optionList[i] == index) {
				this.optionList.splice(i, 1);
				break;
			}
		}
		if (this.optionList.length == 0) {
			this.checkOver();
		} else {
			this.showRandomQuestion();
		}
	},

	checkOver() {
254 255
		if (GameData.questionIndex != this.data.questionList.length - 1) {
			return;
asdf's avatar
asdf committed
256
		}
257 258
		let node = cc.instantiate(this.layerOver);
		node.parent = this.node;
asdf's avatar
asdf committed
259 260 261
	},

	moveToQuestion(ItemAnswer) {
asdf's avatar
.  
asdf committed
262
		GameData.isMoving = true;
asdf's avatar
asdf committed
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
		let index = ItemAnswer.index;
		let question = this.nodeDict.nodQuestionParent.children[index];
		let pos = this.nodeDict.nodQuestionParent.convertToWorldSpaceAR(question.position);
		pos = this.nodeDict.nodAnswerParent.convertToNodeSpaceAR(pos);
		this.playAudioMove();
		cc.tween(ItemAnswer.node)
			.to(0.8, { position: pos })
			.call(() => {
				question.getComponent('ItemQuestion').setChooseRight(ItemAnswer.dragonBone, ItemAnswer.animationName);
				ItemAnswer.node.destroy();
				this.getComponent(cc.Animation).play('animLight');
				this.playAudioMerge();
				cc.tween(question)
					.delay(3)
					.call(() => {
						question.getComponent('ItemQuestion').stopRightAnimation();
						this.getComponent(cc.Animation).play('animDark');
asdf's avatar
.  
asdf committed
280
						GameData.isMoving = false;
asdf's avatar
asdf committed
281 282 283 284 285
					})
					.start()
			})
			.start()
	},
Li Mingzhe's avatar
Li Mingzhe committed
286

asdf's avatar
asdf committed
287 288 289
	updateBtnStatus() {
		if (GameData.questionIndex == 0) {
			this.nodeDict.btnLast.getComponent(cc.Button).interactable = false;
asdf's avatar
.  
asdf committed
290
		} else {
asdf's avatar
asdf committed
291 292 293 294
			this.nodeDict.btnLast.getComponent(cc.Button).interactable = true;
		}
		if (GameData.questionIndex == this.data.questionList.length - 1) {
			this.nodeDict.btnNext.getComponent(cc.Button).interactable = false;
asdf's avatar
.  
asdf committed
295
		} else {
asdf's avatar
asdf committed
296 297 298 299 300 301 302
			this.nodeDict.btnNext.getComponent(cc.Button).interactable = true;
		}
	},

	onTurnLast() {
		this.nodeDict.nodAnswerParent.destroyAllChildren();
		this.nodeDict.nodQuestionParent.destroyAllChildren();
303 304
		cc.audioEngine.stopAll();
		GameData.questionIndex--;
asdf's avatar
asdf committed
305 306 307 308 309 310
		this.initData();
		this.playAudioQuestion();
	},
	onReplay() {
		this.nodeDict.nodAnswerParent.destroyAllChildren();
		this.nodeDict.nodQuestionParent.destroyAllChildren();
311
		cc.audioEngine.stopAll();
asdf's avatar
asdf committed
312 313 314 315 316 317
		this.initData();
		this.startGame();
	},
	onTurnNext() {
		this.nodeDict.nodAnswerParent.destroyAllChildren();
		this.nodeDict.nodQuestionParent.destroyAllChildren();
318 319
		cc.audioEngine.stopAll();
		GameData.questionIndex++;
asdf's avatar
asdf committed
320 321
		this.initData();
		this.startGame();
asdf's avatar
asdf committed
322
	},
Li Mingzhe's avatar
Li Mingzhe committed
323

asdf's avatar
.  
asdf committed
324 325
	buttonListener(button) {
		if (button.node.name == 'btnTitle') {
asdf's avatar
asdf committed
326 327
			if (GameData.audioCount != 0) {
				return;
asdf's avatar
.  
asdf committed
328
			}
asdf's avatar
asdf committed
329
			this.playAudioQuestion(true);
asdf's avatar
asdf committed
330 331 332 333 334 335
		} else if (button.node.name == 'btnLast') {
			this.onTurnLast();
		} else if (button.node.name == 'btnReplay') {
			this.onReplay();
		} else if (button.node.name == 'btnNext') {
			this.onTurnNext();
asdf's avatar
.  
asdf committed
336 337 338
		}
	},

Li Mingzhe's avatar
Li Mingzhe committed
339
});