Commit dafeb013 authored by asdf's avatar asdf

修复bug

parent 8df8c37a
......@@ -65,18 +65,23 @@ cc.Class({
if (window.isPlayEnter) {
return
}
if (!window.isTrainMove) {
return;
}
cc.audioEngine.play(this.audClick, false, 1);
let event = new cc.Event.EventCustom('stopMove', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
// this.data.shortAudio_url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(this.data.shortAudio_url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
cc.audioEngine.play(clip, false, 1);
});
let id = cc.audioEngine.play(clip, false, 1);
let duration = cc.audioEngine.getDuration(id);
cc.tween(this.layerLetters)
.delay(0.2)
.call(() => {
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
......@@ -89,12 +94,15 @@ cc.Class({
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
node.getComponent('ItemLetter').setOldColor();
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}
})
.start();
this.scheduleOnce(() => {
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, Math.max(duration, 0.8))
});
},
// update (dt) {},
});
......@@ -65,18 +65,23 @@ cc.Class({
if (window.isPlayEnter) {
return
}
if (!window.isTrainMove) {
return;
}
cc.audioEngine.play(this.audClick, false, 1);
let event = new cc.Event.EventCustom('stopMove', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
// this.data.shortAudio_url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(this.data.shortAudio_url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
cc.audioEngine.play(clip, false, 1);
});
let id = cc.audioEngine.play(clip, false, 1);
let duration = cc.audioEngine.getDuration(id);
cc.tween(this.layerLetters)
.delay(0.2)
.call(() => {
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
......@@ -89,12 +94,15 @@ cc.Class({
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
node.getComponent('ItemLetter').setOldColor();
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}
})
.start();
this.scheduleOnce(() => {
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, Math.max(duration, 0.8))
});
},
// update (dt) {},
});
......@@ -65,18 +65,23 @@ cc.Class({
if (window.isPlayEnter) {
return
}
if (!window.isTrainMove) {
return;
}
cc.audioEngine.play(this.audClick, false, 1);
let event = new cc.Event.EventCustom('stopMove', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
// this.data.shortAudio_url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(this.data.shortAudio_url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
cc.audioEngine.play(clip, false, 1);
});
let id = cc.audioEngine.play(clip, false, 1);
let duration = cc.audioEngine.getDuration(id);
cc.tween(this.layerLetters)
.delay(0.2)
.call(() => {
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
......@@ -89,12 +94,15 @@ cc.Class({
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
node.getComponent('ItemLetter').setOldColor();
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}
})
.start();
this.scheduleOnce(() => {
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, Math.max(duration, 0.8))
});
},
// update (dt) {},
});
......@@ -65,18 +65,23 @@ cc.Class({
if (window.isPlayEnter) {
return
}
if (!window.isTrainMove) {
return;
}
cc.audioEngine.play(this.audClick, false, 1);
let event = new cc.Event.EventCustom('stopMove', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
// this.data.shortAudio_url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(this.data.shortAudio_url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
cc.audioEngine.play(clip, false, 1);
});
let id = cc.audioEngine.play(clip, false, 1);
let duration = cc.audioEngine.getDuration(id);
cc.tween(this.layerLetters)
.delay(0.2)
.call(() => {
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
......@@ -89,12 +94,15 @@ cc.Class({
for (let i = 0; i < this.layerLetters.children.length; i++) {
let node = this.layerLetters.children[i];
node.getComponent('ItemLetter').setOldColor();
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}
})
.start();
this.scheduleOnce(() => {
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, Math.max(duration, 0.8))
});
},
// update (dt) {},
});
......@@ -33,12 +33,14 @@ cc.Class({
this.speedLevels.on('touchend', this.onSpeedTouchend, this);
this.node.on('showResult', this.onShowResult, this);
this.node.on('showResultDone', this.onShowResultDone, this);
this.node.on('stopMove', this.onStopMove, this);
},
onDisable() {
this.speedLevels.off('touchend', this.onSpeedTouchend, this);
this.node.off('showResult', this.onShowResult, this);
this.node.off('showResultDone', this.onShowResultDone, this);
this.node.off('stopMove', this.onStopMove, this);
},
......@@ -310,6 +312,8 @@ cc.Class({
}
}
}
this.unschedule(this.tFunc1)
this.unschedule(this.tFunc3)
this.unschedule(this.tFunc2)
this.schedule(this.tFunc2, 0.02)
},
......@@ -329,7 +333,7 @@ cc.Class({
return
}
this.layerTrain.x = cc.view.getVisibleSize().width / 2;
this.isTrainMove = true;
window.isTrainMove = true;
this.dragonBone.playAnimation('move', -1);
},
......@@ -358,7 +362,7 @@ cc.Class({
},
update(dt) {
if (!this.isTrainMove) {
if (!window.isTrainMove) {
return;
}
this.layerTrain.x -= dt * this.getSpeed();
......@@ -381,9 +385,6 @@ cc.Class({
onShowResult(event) {
let index = event.getUserData();
this.isTrainMove = false;
this.stopAudioTrainEase();
this.playDragonResult(index);
let node = cc.instantiate(this.pfbLayerResult);
node.parent = this.node;
node.getComponent('LayerResult').setData(this.data.contentObj, index);
......@@ -405,10 +406,17 @@ cc.Class({
// this.dragonBone.playAnimation('normal', -1);
},
onStopMove(event){
let index = event.getUserData();
window.isTrainMove = false;
this.stopAudioTrainEase();
this.playDragonResult(index);
},
onShowResultDone(event) {
this.playAudioTrainEase();
let index = event.getUserData();
this.isTrainMove = true;
this.playAudioTrainEase();
window.isTrainMove = true;
this.dragonBone.playAnimation('move', -1);
this.removeRightChoose(index);
},
......@@ -429,7 +437,7 @@ cc.Class({
showGameOver() {
this.isTrainMove = false;
window.isTrainMove = false;
this.stopAudioTrain();
this.layerOver = cc.instantiate(this.pfbLayerOver);
this.layerOver.parent = this.node;
......
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