Commit f350e187 authored by linzhiguo's avatar linzhiguo

+ 音效

parent 5a614b84
This diff is collapsed.
...@@ -148,11 +148,12 @@ cc.Class({ ...@@ -148,11 +148,12 @@ cc.Class({
// let option = option_node.getComponent(cc.js.getClassByName('WordOption')); // let option = option_node.getComponent(cc.js.getClassByName('WordOption'));
this._test.on('click', ()=>{ this._test.on('click', ()=>{
option.initType(1);
option.setWord('hello');
}); });
cc.find('Canvas/add').on('click', ()=>{ cc.find('Canvas/add').on('click', ()=>{
if (this._btn_start.active == true || this._btn_restart.active == true)
return;
this.pageFinish(); this.pageFinish();
}); });
...@@ -176,6 +177,7 @@ cc.Class({ ...@@ -176,6 +177,7 @@ cc.Class({
let option_node = area.children[i]; let option_node = area.children[i];
let option = option_node.getComponent(cc.js.getClassByName('WordOption')); let option = option_node.getComponent(cc.js.getClassByName('WordOption'));
if (this._touched != true && cc.rect(option_node.getBoundingBoxToWorld()).contains(event.touch._point)){ if (this._touched != true && cc.rect(option_node.getBoundingBoxToWorld()).contains(event.touch._point)){
this.playAudioByName('tap');
this._moved = false; this._moved = false;
this._touched = true; this._touched = true;
selected.copyValues(option); selected.copyValues(option);
...@@ -223,12 +225,10 @@ cc.Class({ ...@@ -223,12 +225,10 @@ cc.Class({
if (cc.rect(item.getBoundingBoxToWorld()).intersects(cc.rect(selected.node.getBoundingBoxToWorld()))){ if (cc.rect(item.getBoundingBoxToWorld()).intersects(cc.rect(selected.node.getBoundingBoxToWorld()))){
let kind = item.getComponent(cc.js.getClassByName('WordKind')); let kind = item.getComponent(cc.js.getClassByName('WordKind'));
if (kind.kind_id != selected.kind_id){ if (kind.kind_id != selected.kind_id){
console.log(kind.kind_id); this.playAudioByName('incorrect');
console.log(selected.kind_id);
break; break;
} }
this.playAudioByName('correct');
let node = cc.instantiate(cc.find('res/option_item')); let node = cc.instantiate(cc.find('res/option_item'));
let ot = node.getComponent(cc.js.getClassByName('WordOption')); let ot = node.getComponent(cc.js.getClassByName('WordOption'));
ot.copyValues(selected); ot.copyValues(selected);
...@@ -254,21 +254,25 @@ cc.Class({ ...@@ -254,21 +254,25 @@ cc.Class({
initButton(){ initButton(){
this._btn_start = cc.find('Canvas/btn_start'); this._btn_start = cc.find('Canvas/btn_start');
this._btn_start.on('click', ()=>{ this._btn_start.on('click', ()=>{
this.playAudioByName('button');
this._btn_start.active = false; this._btn_start.active = false;
this.updateData(); this.updateData();
this.upForeground(()=>{ this.upForeground(()=>{
this._moved = true; this._moved = true;
this.playAudioByName('up');
}); });
}); });
this._btn_start.active = true; this._btn_start.active = true;
this._btn_restart = cc.find('Canvas/btn_restart'); this._btn_restart = cc.find('Canvas/btn_restart');
this._btn_restart.on('click', ()=>{ this._btn_restart.on('click', ()=>{
this.playAudioByName('button');
this._btn_restart.active = false; this._btn_restart.active = false;
this.downForeground(()=>{ // this.downForeground(()=>{
this._btn_start.active = true; // this._btn_start.active = true;
this.resetData(); // this.resetData();
}); // });
this.resetData();
}); });
}, },
...@@ -341,7 +345,7 @@ cc.Class({ ...@@ -341,7 +345,7 @@ cc.Class({
}, },
currentStarIdx: null, currentStarIdx: null,
showStar() { showStar(cb) {
if (!this.currentStarIdx) { if (!this.currentStarIdx) {
this.currentStarIdx = 0; this.currentStarIdx = 0;
} }
...@@ -386,7 +390,7 @@ cc.Class({ ...@@ -386,7 +390,7 @@ cc.Class({
.delay(0.6) .delay(0.6)
.to(0.8, { scale: 0 }, { easing: 'quadOut' }) .to(0.8, { scale: 0 }, { easing: 'quadOut' })
.call(() => { .call(() => {
// this.checkGameEnd(); cb && cb();
}) })
.start(); .start();
...@@ -525,21 +529,38 @@ cc.Class({ ...@@ -525,21 +529,38 @@ cc.Class({
pageFinish(){ pageFinish(){
this._page_idx ++; this._page_idx ++;
if (this._page_idx >= this._page_max){ this.downForeground(()=>{
this.showStar(); if (this._page_idx >= this._page_max){
this._star_idx ++; this.playAudioByName('star');
if (this._star_idx >= this.data.stars.length){ this.playAudioByName('complete');
this.completeTest(); this.showStar(()=>{
return; this._star_idx ++;
if (this._star_idx >= this.data.stars.length){
this.completeTest();
return;
}
this._page_max = this.data.stars[this._star_idx].length;
this._page_idx = 0;
this.upForeground(()=>{
this.updateData();
this.playAudioByName('up');
});
});
} }
this._page_max = this.data.stars[this._star_idx].length; else{
this._page_idx = 0; this.upForeground(()=>{
} this.updateData();
this.updateData(); this.playAudioByName('up');
});
}
});
}, },
completeTest(){ completeTest(){
this.completeAnimation(); this.completeAnimation();
this.playAudioByName('sahua');
this.playAudioByName('button');
this.playAudioByName('up');
this._btn_restart.active = true; this._btn_restart.active = true;
this._moved = false; this._moved = false;
//this.resetData(); //this.resetData();
......
...@@ -64,7 +64,7 @@ cc.Class({ ...@@ -64,7 +64,7 @@ cc.Class({
this.btn_sound.node.active = true; this.btn_sound.node.active = true;
} }
this.kind_id = data.kind; this.kind_id = data.kind;
//this.layout.node.removeAllChildren(); this.layout.node.removeAllChildren();
}, },
initData(){ initData(){
......
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