Commit ef072d79 authored by Li MingZhe's avatar Li MingZhe

fear: 开始按钮

parent 061c9f6a
......@@ -2,7 +2,7 @@ import { Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListene
import {
Label,
MySprite, ShapeRect, tweenChange,
MySprite, removeItemFromArr, ShapeRect, tweenChange,
} from './Unit';
import { res, resAudio } from './resources';
......@@ -81,6 +81,8 @@ export class PlayComponent implements OnInit, OnDestroy {
rightAnswer: Answer;
startBtn;
startLayer;
@HostListener('window:resize', ['$event'])
onResize(event) {
......@@ -551,7 +553,29 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initStage();
this.showNewExerices();
this.addStartLayer();
// this.showNewExerices();
}
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;
this.renderArr.push(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;
}
initBg() {
......@@ -584,11 +608,19 @@ export class PlayComponent implements OnInit, OnDestroy {
mapDown(event) {
if(this.startBtn && this.checkClickTarget(this.startBtn)){
console.log(' in startbtn')
this.startBtnClick();
return;
}
console.log(this.canTouch);
if (!this.canTouch) {
return;
}
if(this.checkClickTarget(this.stage.audioAni.bg)){
if(this.stage.audioAni.playing){
this.stage.audioAni.pauseAudio();
......@@ -660,6 +692,13 @@ export class PlayComponent implements OnInit, OnDestroy {
}
startBtnClick() {
removeItemFromArr(this.renderArr, this.startLayer);
this.startBtn = null;
this.showNewExerices();
}
clickAnswer(flag){
this.canTouch = false;
......
......@@ -44,6 +44,9 @@ const res = [
['petal_6', "assets/play/petal_6.png"],
['petal_7', "assets/play/petal_7.png"],
['petal_8', "assets/play/petal_8.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