Commit dafeb013 authored by asdf's avatar asdf

修复bug

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