Commit 8c6bda2d authored by Chen Jiping's avatar Chen Jiping

完善

parent dd10053f
......@@ -107,6 +107,8 @@ export class PlayComponent implements OnInit, OnDestroy {
playingPic;
playingPic_1;
//正在播放
playing;
......@@ -347,9 +349,6 @@ export class PlayComponent implements OnInit, OnDestroy {
* @param callback
*/
playPracticeAudio(key, now = false, callback = null){
this.playPic.alpha = 0;
this.playingPic.alpha = 1;
this.playAudio(key, now, callback);
......@@ -359,26 +358,66 @@ export class PlayComponent implements OnInit, OnDestroy {
}
showPlayStauts(){
const show1 = () =>{
if(this.playing){
this.playPic.alpha = 0;
this.playingPic.alpha = 1;
this.playingPic_1.alpha = 0;
if(this.playPic.alpha == 0){
this.playingPic.alpha = 0;
this.playPic.alpha = 1
setTimeout(() => {
show2();
}, 500);
}
else{
this.playingPic.alpha = 1;
this.setPause();
}
};
const show2 = () =>{
if(this.playing){
this.playPic.alpha = 0;
this.playingPic.alpha = 0;
this.playingPic_1.alpha = 1;
setTimeout(() => {
show3();
}, 500);
}
else{
this.setPause();
}
};
const show3 = () =>{
if(this.playing){
this.playPic.alpha = 1;
this.playingPic.alpha = 0;
this.playingPic_1.alpha = 0;
setTimeout(() => {
this.showPlayStauts();
}, 1000);
show1();
}, 500);
}
else{
this.setPause();
}
};
show1();
}
setPause(){
this.playingPic.alpha = 0;
this.playPic.alpha = 1;
this.playingPic_1.alpha = 0;
}
}
playAudio(key, now = false, callback = null) {
......@@ -408,6 +447,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.playingPic.alpha = 0;
this.playingPic_1.alpha = 0;
this.pauseAudio(key, callback);
this.playing =false;
......@@ -788,6 +829,17 @@ export class PlayComponent implements OnInit, OnDestroy {
this.renderArr.push(playingPic);
this.playingPic = playingPic;
const playingPic_1 = new MySprite();
playingPic_1.init(this.images.get('playing_1'));
playingPic_1.x = btnPlay.x;
playingPic_1.y = btnPlay.y;
playingPic_1.alpha = 0;
playingPic_1.setScaleXY(this.mapScale);
this.renderArr.push(playingPic_1);
this.playingPic_1 = playingPic_1;
}
initPic() {
......@@ -1393,6 +1445,9 @@ export class PlayComponent implements OnInit, OnDestroy {
//如果未全部结束,则初始化下一个练习题
if(!end){
this.showPrompt();
setTimeout(() => {
tweenChange(cover, {alpha: 0}, 6, ()=>{
......@@ -1403,6 +1458,32 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
/**
* 显示练习题结束提示
*/
showPrompt(){
//显示练习题剩余提示
const prompt = new MySprite();
prompt.init(this.images.get('prompt'));
prompt.setScaleXY(this.mapScale);
prompt.y = this.canvasHeight/2;
prompt.x = this.canvasWidth/2;
this.endPageArr.push(prompt);
let prompt_val = new Label();
prompt_val.text = (this.nextPracticeIndex - 1) + " | " + this.data.practices.length;
prompt_val.textAlign='middle';
prompt_val.fontSize = 50;
prompt_val.fontName = "ARIALBD";
prompt_val.fontColor = "#FFFFFF";
prompt_val.refreshSize();
prompt_val.x = -prompt_val.width/2;
prompt_val.y = 0;
prompt.addChild(prompt_val);
prompt.childDepandAlpha = true;
}
/**
* 添加结束花辨效果
*/
......@@ -1499,6 +1580,13 @@ export class PlayComponent implements OnInit, OnDestroy {
return;
}
if (this.checkClickTarget(this.playingPic_1) && this.playing) {
this.pausePracticeAudio('practice_' + (this.nextPracticeIndex - 1));
return;
}
}
mapMove(event) {
......@@ -1548,13 +1636,13 @@ export class PlayComponent implements OnInit, OnDestroy {
};
let out = -bullet_pic.height;
tweenChange(bullet.pic, {y: out}, 1, ()=>{
let bulletTween = tweenChange(bullet.pic, {y: out}, 1, ()=>{
removeItemFromArr(this.bulletRenderArr, bullet);
},null,()=>{
this.checkHit(bullet);
this.checkHit(bullet, bulletTween);
});
......@@ -1602,8 +1690,9 @@ export class PlayComponent implements OnInit, OnDestroy {
/**
* 检查是否碰撞
* @param item
* @param bulletTween
*/
checkHit(item){
checkHit(item, bulletTween){
if(!item){
return;
......@@ -1636,11 +1725,19 @@ export class PlayComponent implements OnInit, OnDestroy {
break;
}
bulletTween.pause();
//延迟隐藏子弹
setTimeout(() => {
item.pic.scaleY = 0;
item.pic.scaleX = 0;
item.pic.alpha=0;
bulletTween.resume();
}, 100);
item.hit = true;
//正确答案
......
......@@ -23,8 +23,11 @@ const res = [
['play', "assets/play/play.png"],
['playing', "assets/play/playing.png"],
['playing_1', "assets/play/playing_1.png"],
['start', "assets/play/start.png"],
['restart', "assets/play/restart.png"]
['restart', "assets/play/restart.png"],
['prompt', "assets/play/prompt.png"]
];
......
src/assets/play/play.png

21.5 KB | W: | H:

src/assets/play/play.png

21.5 KB | W: | H:

src/assets/play/play.png
src/assets/play/play.png
src/assets/play/play.png
src/assets/play/play.png
  • 2-up
  • Swipe
  • Onion skin
src/assets/play/playing.png

22.2 KB | W: | H:

src/assets/play/playing.png

21.9 KB | W: | H:

src/assets/play/playing.png
src/assets/play/playing.png
src/assets/play/playing.png
src/assets/play/playing.png
  • 2-up
  • Swipe
  • Onion skin
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