Commit 4c2f4568 authored by Chen Jiping's avatar Chen Jiping

完善

parent 9fc71c62
...@@ -26,6 +26,9 @@ export class Exercises{ ...@@ -26,6 +26,9 @@ export class Exercises{
/**显示亮光 */ /**显示亮光 */
lightShow = true; lightShow = true;
/**正在显示亮光 */
lighting = false;
audioUrl: string; audioUrl: string;
/**内容类型:T-文本,P-图片;默认为文本 */ /**内容类型:T-文本,P-图片;默认为文本 */
...@@ -43,6 +46,8 @@ export class Exercises{ ...@@ -43,6 +46,8 @@ export class Exercises{
this.lightShow = true; this.lightShow = true;
this.lighting = false;
this.audioUrl = ''; this.audioUrl = '';
} }
} }
\ No newline at end of file
...@@ -80,6 +80,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -80,6 +80,8 @@ export class PlayComponent implements OnInit, OnDestroy {
canClickMonkey = false; canClickMonkey = false;
canOverCard = true;
showPetalStatus = false; showPetalStatus = false;
/**背景图片 */ /**背景图片 */
...@@ -617,6 +619,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -617,6 +619,8 @@ export class PlayComponent implements OnInit, OnDestroy {
}; };
initCardX(); initCardX();
this.canOverCard = true;
} }
...@@ -773,21 +777,23 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -773,21 +777,23 @@ export class PlayComponent implements OnInit, OnDestroy {
cardObj.light = cardLight; cardObj.light = cardLight;
cardBaseboard.addChild(cardLight); cardBaseboard.addChild(cardLight);
cardBack.x = cardLight.x;
cardBack.y = cardLight.y;
cardBaseboard.addChild(cardBack);
//卡片正面 //卡片正面
const cardFront = new MySprite(); const cardFront = new MySprite();
cardFront.init(this.images.get("card-front")); cardFront.init(this.images.get("card-front"));
cardFront.setScaleXY(this.mapScale); cardFront.setScaleXY(this.mapScale);
cardFront.x = cardBack.x; cardFront.x = cardLight.x;
cardFront.y = cardBack.y; cardFront.y = cardLight.y;
cardFront.alpha = 0; cardFront.alpha = 0;
cardFront.visible = true; cardFront.visible = true;
cardObj.front = cardFront; cardObj.front = cardFront;
cardBaseboard.addChild(cardFront); cardBaseboard.addChild(cardFront);
cardBack.x = cardLight.x;
cardBack.y = cardLight.y;
cardBaseboard.addChild(cardBack);
//设置内容 //设置内容
this.setContent(exercises, cardFront, cardObj); this.setContent(exercises, cardFront, cardObj);
...@@ -1066,16 +1072,25 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1066,16 +1072,25 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
//停止闪烁
card.lightShow = false;
card.light.alpha = 0;
//停止闪烁
this.stopLightMonkey();
//显示背面,则翻转 //显示背面,则翻转
if (card.curShow == '0') { if (card.curShow == '0') {
if(!this.canOverCard){
return;
}
//停止闪烁
card.lightShow = false;
card.light.alpha = 0;
//停止闪烁
this.stopLightMonkey();
//禁止翻动卡片
this.canOverCard = false;
this.overCard(card.baseboard, () => { this.overCard(card.baseboard, () => {
this.canClickMonkey = true; this.canClickMonkey = true;
}); });
...@@ -1090,7 +1105,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1090,7 +1105,7 @@ export class PlayComponent implements OnInit, OnDestroy {
//卡片未到顶部,则将下一个卡片点亮 //卡片未到顶部,则将下一个卡片点亮
if (card.index < this.exercisesArr.length - 1) { if (card.index < this.exercisesArr.length - 1) {
this.lightCard(this.exercisesArr[card.index + 1]); //this.lightCard(this.exercisesArr[card.index + 1]);
} }
else { else {
this.peach.canRotate = true; this.peach.canRotate = true;
...@@ -1165,11 +1180,30 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1165,11 +1180,30 @@ export class PlayComponent implements OnInit, OnDestroy {
monkey.curFloor = monkey.curFloor + 1; monkey.curFloor = monkey.curFloor + 1;
console.log('monkey cur floor', monkey.curFloor); console.log('monkey cur floor', monkey.curFloor);
this.canClickMonkey = true; this.canClickMonkey = true;
this.canOverCard = true;
let card = this.exercisesArr[monkey.curFloor];
if(card.curShow == '0' && !card.lighting){
card.lightShow = true;
this.lightCard(card);
}
}); });
} }
} }
else { else {
//还有卡片未被翻过来,则不跑向成功
for(let i = 0; i < this.exercisesArr.length; ++ i){
if(this.exercisesArr[i].curShow == '0'){
return;
}
}
let toX = this.peach.initX - monkey.baseboard.getBoundingBox().width / 2; let toX = this.peach.initX - monkey.baseboard.getBoundingBox().width / 2;
let toY = this.peach.initY - monkey.baseboard.getBoundingBox().height / 2 + 30 * this.mapScale; let toY = this.peach.initY - monkey.baseboard.getBoundingBox().height / 2 + 30 * this.mapScale;
...@@ -1354,10 +1388,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1354,10 +1388,12 @@ export class PlayComponent implements OnInit, OnDestroy {
lightCard(card) { lightCard(card) {
if (!card.lightShow) { if (!card.lightShow) {
card.lighting = false;
return; return;
} }
card.lighting = true;
let alpha = card.light.alpha; let alpha = card.light.alpha;
tweenChange(card.light, { alpha: 1 }, 0.4, () => { tweenChange(card.light, { alpha: 1 }, 0.4, () => {
...@@ -1499,6 +1535,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1499,6 +1535,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.playAudio('peachShow'); this.playAudio('peachShow');
this.canOverCard = true;
//桃子显示并放大 //桃子显示并放大
tweenChange(this.peach.peach, { scaleX: this.mapScale * 1.2, scaleY: this.mapScale * 1.2, alpha: 1 }, 0.3, () => { tweenChange(this.peach.peach, { scaleX: this.mapScale * 1.2, scaleY: this.mapScale * 1.2, alpha: 1 }, 0.3, () => {
...@@ -1507,9 +1545,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1507,9 +1545,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this.peach.light.alpha = 1; this.peach.light.alpha = 1;
setTimeout(() => { setTimeout(() => {
this.peach.light.alpha = 0; tweenChange(this.peach.light, {alpha : 0}, 0.5)
this.peach.canRotate = true; this.peach.canRotate = true;
}, 300); }, 1000);
}); });
//显示卡片 //显示卡片
...@@ -1520,11 +1558,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1520,11 +1558,11 @@ export class PlayComponent implements OnInit, OnDestroy {
exercises.front.alpha = 1; exercises.front.alpha = 1;
exercises.back.alpha = 1; exercises.back.alpha = 1;
exercises.baseboard.scaleY = 0;
if (i == this.exercisesArr.length - 1) { if (i == this.exercisesArr.length - 1) {
this.overCard(exercises.baseboard, () => { tweenChange(exercises.baseboard, {scaleY : this.mapScale}, 0.3, () => {
this.playAudio('monkey'); this.playAudio('monkey');
...@@ -1543,7 +1581,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1543,7 +1581,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
else { else {
this.overCard(exercises.baseboard); tweenChange(exercises.baseboard, {scaleY : this.mapScale}, 0.3)
} }
} }
...@@ -1569,6 +1607,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1569,6 +1607,9 @@ export class PlayComponent implements OnInit, OnDestroy {
card.back.alpha = 0; card.back.alpha = 0;
tweenChange(card.front, { alpha: 0 }, 0.3, () => { tweenChange(card.front, { alpha: 0 }, 0.3, () => {
this.overCard(card.baseboard);
//重置内容 //重置内容
card.resetContent(); card.resetContent();
...@@ -1662,10 +1703,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1662,10 +1703,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.showPetal(pos); this.showPetal(pos);
//1秒后停止撒花 //停止撒花
setTimeout(() => { setTimeout(() => {
this.showPetalStatus = false; this.showPetalStatus = false;
}, 800); }, 500);
this.rotateLight(); this.rotateLight();
...@@ -1730,7 +1771,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1730,7 +1771,7 @@ export class PlayComponent implements OnInit, OnDestroy {
setTimeout(() => { setTimeout(() => {
this.showPetal(pos); this.showPetal(pos);
}, 100); }, 50);
} }
/** /**
...@@ -1759,7 +1800,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1759,7 +1800,7 @@ export class PlayComponent implements OnInit, OnDestroy {
petal.y = startY - petal.height / 2 * petal.scaleY; petal.y = startY - petal.height / 2 * petal.scaleY;
const randomT = 2 + Math.random() * 5; const randomT = 0.5 + Math.random() * 2;
petal['time'] = randomT; petal['time'] = randomT;
let randomTR = 360 * Math.random(); // - 180; let randomTR = 360 * Math.random(); // - 180;
......
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