Commit 58646637 authored by Chen Jiping's avatar Chen Jiping

增加小手提示

parent 7748124c
......@@ -11,7 +11,7 @@ export class AudioAnimation {
images = new Map();
bg : ShapeRect;
bg: ShapeRect;
scaleX = 1;
......@@ -29,6 +29,8 @@ export class AudioAnimation {
hideFlag = true;
fingerPic;
/**
* 设置播放帧图片
* @param images
......@@ -38,7 +40,7 @@ export class AudioAnimation {
this.images = images;
}
setXY(x, y){
setXY(x, y) {
this.x = x;
this.y = y;
}
......@@ -56,6 +58,10 @@ export class AudioAnimation {
return;
}
this.scaleX = scaleX;
this.scaleY = sacleY;
const bg = new ShapeRect();
const getAudioPic = (index) => {
......@@ -71,7 +77,7 @@ export class AudioAnimation {
};
const playPic1 = getAudioPic(1);
if (show) {
playPic1.alpha = 1;
......@@ -90,7 +96,7 @@ export class AudioAnimation {
const playPic3 = getAudioPic(3);
this.playPic3 = playPic3;
bg.setSize(playPic1.getBoundingBox().width, playPic1.getBoundingBox().height);
bg.alpha = 0;
this.bg = bg;
......@@ -104,6 +110,16 @@ export class AudioAnimation {
parent.addChild(bg);
}
const finger = new MySprite();
finger.init(this.images.get("finger"), 0, 0);
finger.scaleX = this.scaleX;
finger.scaleY = this.scaleY;
finger.alpha = 0;
this.fingerPic = finger;
finger.x = bg.width;
finger.y = bg.height;
this.fingerPic.canShow = true;
bg.addChild(finger);
}
/**
......@@ -115,13 +131,13 @@ export class AudioAnimation {
const setPause = () => {
if(this.hideFlag){
if (this.hideFlag) {
this.playPic1.alpha = 0;
}
else{
else {
this.playPic1.alpha = 1;
}
this.playPic2.alpha = 0;
this.playPic3.alpha = 0;
}
......@@ -194,14 +210,14 @@ export class AudioAnimation {
this.curAudio = audio;
audio.onended = () => {
this.playing = false;
if (callback) {
callback();
}
};
audio.play();
this.playing = true;
......@@ -252,7 +268,7 @@ export class AudioAnimation {
/**
* 显示播放动画
*/
show(){
show() {
this.hideFlag = false;
......@@ -260,4 +276,33 @@ export class AudioAnimation {
this.playPic2.alpha = 0;
this.playPic3.alpha = 0;
}
showFinger() {
if (!this.fingerPic.canShow) {
return;
}
this.fingerPic.alpha = 1;
let sX = this.fingerPic.x;
let sY = this.fingerPic.y;
let toX = this.bg.width / 2;
let toY = this.bg.height / 2;
tweenChange(this.fingerPic, { x: toX, y: toY }, 0.5, () => {
tweenChange(this.fingerPic, { alpha: 0 }, 0.2, () => {
this.fingerPic.x = sX;
this.fingerPic.y = sY;
setTimeout(() => {
this.showFinger();
}, 100);
})
});
}
hideFinger(){
this.fingerPic.canShow = false;
}
}
\ No newline at end of file
......@@ -838,9 +838,13 @@ export class PlayComponent implements OnInit, OnDestroy {
showNextExercise() {
let exercise = this.tempExerciseArr.shift();
this.audioTool.pauseAudio();
//如果存在,则加载;不存在,则表示结束
if (exercise) {
this.canPlay = false;
this.curIndex += 1;
this.stage.setPromptText(this.curIndex + "/" + this.exerciseArr.length);
......@@ -854,7 +858,9 @@ export class PlayComponent implements OnInit, OnDestroy {
if (i == 0) {
this.leftBox.showBox(answers[i], () => {
this.canTouch = true;
this.canPlay = true;
this.audioTool.fingerPic.canShow = true;
this.audioTool.showFinger();
});
}
else if (i == 1) {
......@@ -896,6 +902,10 @@ export class PlayComponent implements OnInit, OnDestroy {
let audio = this.curExercise.listeningAudio;
this.audioTool.playAudio(audio, true);
this.audioTool.hideFinger();
this.canPlay = true;
}
}
......@@ -977,6 +987,10 @@ export class PlayComponent implements OnInit, OnDestroy {
clickBox(box) {
if(!this.canPlay){
return;
}
this.canTouch = false;
box.click(() => {
......
......@@ -25,6 +25,8 @@ const res = [
['player', 'assets/play/player.png'],
['sweat', 'assets/play/sweat.png'],
['finger', 'assets/play/finger.png'],
['petal_1', "assets/play/petal_1.png"],
['petal_2', "assets/play/petal_2.png"],
['petal_3', "assets/play/petal_3.png"],
......
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