Commit 0f3fe549 authored by WangFan's avatar WangFan

完善基础流程

parent 8d34e5f6
This diff is collapsed.
......@@ -32,10 +32,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initGame();
}
private sentence_list: Array<string>;
private current:number=0;
initData() {
this.sentence_list = [
'While there is life there is hope', 'apple'
]
}
private layer_bg: cc.Node;
......@@ -48,6 +51,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private time: cc.Node;
private microphone_area: cc.Node;
private coin_area: cc.Node;
initView() {
this.layer_bg = pg.view.find(this, "layer_bg")
......@@ -59,20 +63,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.microphone_area = pg.view.find(this.sentence_box, "microphone_area");
this.time_area = pg.view.find(this.microphone_area, "time_area")
this.time = pg.view.find(this.time_area, "time")
this.coin_area = pg.view.find(this.layer_game, "coin_area")
}
initListener() {
this.initTween()
}
// 场景初始动画
initTween() {
this.setSentence()
cc.tween(this.sentence_box).to(0.5, { y: -375 }).start()
setTimeout(() => {
pg.view.visible(this.time_area, true);
}, 0.5 * 1000)
this.setTimeCountdown()
}
setTimeCountdown(){
pg.view.visible(this.time_area, true)
let time = 10;
let timer = null;
timer = setInterval(() => {
......@@ -86,6 +91,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
clearInterval(timer)
}
}, 1000)
setTimeout(() => {
this.stopBgAnimation()
this.coinShow()
}, 15 * 1000)
}
setSentence(){
let sentence = pg.view.find(this.sentence_box,'sentence');
pg.view.setString(sentence,this.sentence_list[this.current])
}
microphoneAreaChange() {
......@@ -101,27 +115,46 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.Tween.stopAllByTarget(icon_recording);
pg.view.visible(icon_recording, false)
}
playBgAnimation(){
let bg_tween = pg.view.find(this.layer_bg,"tween");
playBgAnimation() {
let bg_tween = pg.view.find(this.layer_bg, "tween");
// 背景动画报错,暂时注释
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"mountain2/mountain2_ske"), 'animation', false);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"mountain2/mountain2_ske"), 'animation', true);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"mountain2_grass2/mountain2_grass2_ske"), 'animation', false);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"cloud/cloud_ske"), 'animation', false);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"tree/tree_ske"), 'animation', false);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"grass2/grass2_ske"), 'animation', false);
// pg.view.playSpineAnimation(pg.view.find(bg_tween,"mountain1_grass1/mountain1_grass1_ske"), 'animation', false);
let icon_mountain = pg.view.find(bg_tween,"icon_mountain");
let icon_mountain = pg.view.find(bg_tween, "icon_mountain");
pg.view.visible(icon_mountain, true)
cc.tween(icon_mountain).to(0.5, { opacity: 0 }).to(0.3, { opacity: 255 }).union().repeatForever().start();
}
stopBgAnimation(){
let bg_tween = pg.view.find(this.layer_bg,"tween");
let icon_mountain = pg.view.find(bg_tween,"icon_mountain");
stopBgAnimation() {
let bg_tween = pg.view.find(this.layer_bg, "tween");
let icon_mountain = pg.view.find(bg_tween, "icon_mountain");
cc.Tween.stopAllByTarget(icon_mountain);
pg.view.visible(icon_mountain, false)
}
coinShow() {
pg.view.visible(this.time_area, false)
pg.view.visible(this.coin_area, true)
let coins = pg.view.find(this.coin_area, 'coins');
// pg.view.visible(pg.view.find(coins,"coin1/coin_static"), false)
// pg.view.playSpineAnimation(pg.view.find(coins,"coin1/coin_ske"), 'animation', false);
setTimeout(() => {
pg.view.visible(this.coin_area, false)
this.current++;
if(this.current===this.sentence_list.length){
pg.view.visible(this.layer_game,false)
pg.view.visible(this.layer_finish,true)
}else{
this.setSentence();
this.setTimeCountdown()
}
}, 2 * 1000)
}
initGame() {
}
......
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