Commit f350e187 authored by linzhiguo's avatar linzhiguo

+ 音效

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