Commit cac2c33e authored by limingzhe's avatar limingzhe

fix: 火箭没飞出屏幕问题

parent 5bd975e8
...@@ -17,7 +17,6 @@ import {Subject} from 'rxjs'; ...@@ -17,7 +17,6 @@ import {Subject} from 'rxjs';
import {debounceTime} from 'rxjs/operators'; import {debounceTime} from 'rxjs/operators';
import TWEEN from '@tweenjs/tween.js'; import TWEEN from '@tweenjs/tween.js';
import {tar} from "compressing";
@Component({ @Component({
...@@ -82,6 +81,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -82,6 +81,7 @@ export class PlayComponent implements OnInit, OnDestroy {
private endPageArr: any; private endPageArr: any;
private petalTime: number; private petalTime: number;
private isFly: boolean; private isFly: boolean;
private rocketBase: MySprite;
@HostListener('window:resize', ['$event']) @HostListener('window:resize', ['$event'])
...@@ -436,6 +436,21 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -436,6 +436,21 @@ export class PlayComponent implements OnInit, OnDestroy {
this.data.pic_url = 'assets/play/default/pic.jpg'; this.data.pic_url = 'assets/play/default/pic.jpg';
this.data.pic_url_2 = 'assets/play/default/pic.jpg'; this.data.pic_url_2 = 'assets/play/default/pic.jpg';
} }
if (!this.data.sentences) {
this.data.sentences = [
{
text: '1. test sentence ____ .'
},
{
text: '2. test sentence ____ .'
}
];
}
if (!this.data.audio_url) {
this.data.audio_url = 'assets/play/default/audio.mp3';
}
} }
...@@ -520,6 +535,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -520,6 +535,7 @@ export class PlayComponent implements OnInit, OnDestroy {
rocketBase.x = this.borad.x; rocketBase.x = this.borad.x;
rocketBase.y = this.canvasHeight - 20 * this.mapScale; rocketBase.y = this.canvasHeight - 20 * this.mapScale;
rocketBase.setScaleXY(this.mapScale); rocketBase.setScaleXY(this.mapScale);
this.rocketBase = rocketBase;
const rocket = this.createSprite('rocket'); const rocket = this.createSprite('rocket');
rocket.y = -rocket.height / 2 - 30; rocket.y = -rocket.height / 2 - 30;
...@@ -655,7 +671,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -655,7 +671,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const labelOffX = 10; const labelOffX = 10;
const labelMaxWidth = sentenceBg.width - labelOffX * 2; const labelMaxWidth = sentenceBg.width - labelOffX * 2;
const label = new Label(); const label = new Label();
label.text = sentence.text + 'Fg'; label.text = sentence.text;
label.fontColor = '#f3f1da'; label.fontColor = '#f3f1da';
label.fontSize = 45; label.fontSize = 45;
label.fontName = 'MMTextBook'; label.fontName = 'MMTextBook';
...@@ -916,13 +932,23 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -916,13 +932,23 @@ export class PlayComponent implements OnInit, OnDestroy {
return; return;
} }
} }
if (this.isFly) {
return;
}
this.isFly = true;
this.showSmoke(); this.showSmoke();
this.animationId = setTimeout(() => {
this.rocketFly();
}, 100);
} }
private rocketFly() { private rocketFly() {
const flyTime = 2.7 ; const flyTime = 2.7 ;
tweenChange(this.rocket, {x: this.rocket.x, y: -this.canvasHeight}, flyTime, () => { tweenChange(this.rocket, {x: this.rocket.x, y: -(this.canvasHeight * 1.5 + this.rocket.height) / this.rocketBase.scaleY}, flyTime, () => {
this.showEndPatal(); this.showEndPatal();
}, TWEEN.Easing.Quintic.In); }, TWEEN.Easing.Quintic.In);
...@@ -950,12 +976,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -950,12 +976,10 @@ export class PlayComponent implements OnInit, OnDestroy {
const shakeAnima = (data) => { const shakeAnima = (data) => {
const offX = data[0] / 3; const offX = data[0] / 3;
const time = shakeTime; tweenChange(this.rocket, {x: baseX + offX}, shakeTime, () => {
tweenChange(this.rocket, {x: baseX + offX}, time, () => {
if (shakeOffArr.length > 0) { if (shakeOffArr.length > 0) {
const shakeData = shakeOffArr.shift(); const shakeData = shakeOffArr.shift();
shakeAnima(shakeData); shakeAnima(shakeData);
} else {
} }
}); });
} }
...@@ -1045,18 +1069,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1045,18 +1069,13 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
private showSmoke() { private showSmoke() {
if (this.isFly) {
return;
}
this.isFly = true;
const anima = new MyAnimation(); const anima = new MyAnimation();
anima.y = this.rocket.height / 2 - 30; anima.y = this.rocket.height / 2 - 30;
this.rocket.addChild(anima, -1); this.rocket.addChild(anima, -1);
for (let i = 1; i < 10; i++) { for (let i = 1; i < 10; i++) {
const key = 'smoke_' + i; anima.addFrameByImg(this.images.get('smoke_' + i));
anima.addFrameByImg(this.images.get(key));
} }
anima.delayPerUnit = 0.1; anima.delayPerUnit = 0.1;
anima.loop = false; anima.loop = false;
...@@ -1067,10 +1086,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1067,10 +1086,6 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
anima.play(); anima.play();
this.animationId = setTimeout(() => {
this.rocketFly();
}, 100);
this.playAudio('smoke_mp3'); this.playAudio('smoke_mp3');
} }
......
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