Commit fb0c9675 authored by Li MingZhe's avatar Li MingZhe

feat: 开始按钮

parent 569cbdd4
......@@ -3,7 +3,7 @@ import { Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListene
import {
Label,
MyAnimation,
MySprite, shake, ShapeRect, tweenChange,
MySprite, removeItemFromArr, shake, ShapeRect, tweenChange,
} from './Unit';
import { res, resAudio } from './resources';
......@@ -93,6 +93,9 @@ export class PlayComponent implements OnInit, OnDestroy {
timeId = null;
startBtn;
startLayer;
@HostListener('window:resize', ['$event'])
onResize(event) {
this.winResizeEventStream.next();
......@@ -635,9 +638,28 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initBg();
this.showNext();
this.initMagnifier();
this.addStartLayer();
}
addStartLayer() {
const startLayer = new ShapeRect();
startLayer.setSize(this.canvasWidth, this.canvasHeight);
startLayer.alpha = 0.5;
startLayer.fillColor = "#000000";
startLayer.x = 0;
startLayer.y = 0;
this.startLayer = startLayer;
const startBtn = new MySprite();
startBtn.init(this.images.get('start_btn'));
startBtn.setScaleXY(this.mapScale);
startBtn.x = this.canvasWidth / 2;
startBtn.y = this.canvasHeight / 2;
startLayer.addChild(startBtn);
this.startBtn = startBtn;
}
......@@ -974,6 +996,12 @@ export class PlayComponent implements OnInit, OnDestroy {
mapDown(event) {
if(this.startBtn && this.checkClickTarget(this.startBtn)){
console.log(' in startbtn')
this.startBtnClick();
return;
}
if (!this.canTouch) {
return;
}
......@@ -1054,6 +1082,15 @@ export class PlayComponent implements OnInit, OnDestroy {
}
startBtnClick() {
// removeItemFromArr(this.renderArr, this.startLayer);
this.startLayer = null;
this.startBtn = null;
this.initMagnifier();
this.showNext();
}
update() {
......@@ -1075,6 +1112,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.updateArr(this.textLabelArr);
this.updateArr(this.endRenderArr);
if (this.startLayer) {
this.startLayer.update();
}
}
......
......@@ -34,6 +34,9 @@ const res = [
['bg_wrong', "assets/play/bg_wrong.png"],
['bg_zi', "assets/play/bg_zi.png"],
['icon_tiao', "assets/play/icon_tiao.png"],
['start_btn', "assets/play/start_btn.png"],
];
......
This diff is collapsed.
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