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