123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import BasicView from "../../../Engine/Basic/BasicView";
- import { _ECommonState, _EJsonRes, _IViewConfig } from "../../../Engine/Data/CommonDataType";
- import EventManager from "../../../Engine/Event/EventManager";
- import TimeManager from "../../../Engine/Time/TimeManager";
- import Tool from "../../../Engine/Tool/Tool";
- import GameManager from "../../Game/GameManager";
- import { ConstObject } from "../../Data/GameDataType";
- import GameMusicResData from "../../Game/Data/GameMusicResData";
- import GameEventName from "../../Event/GameEventName";
- import SDKManager from "../../SDK/SDKManager";
- import GameView from "../GameView/GameView";
- import HintView from "../HintView/HintView";
- import JsonResources from "../../../Engine/Resources/JsonResources";
- /**
- * 暂停页
- */
- export default class PauseView extends BasicView {
- public static resPath: string = "PauseView";
- protected _initView(): void {
- ConstObject.GameState = _ECommonState.Pause;
- TimeManager.pause();
- let resetButton: fgui.GComponent = this.fgui.getChild("resetButton").asCom;
- Tool.Tool2D.Button.addEvent(resetButton, {
- "touchend": () => {
- this.onReset();
- }
- }, this.fgui.id, 0.9, 0.9, 0, false);
- let continueButton: fgui.GComponent = this.fgui.getChild("continueButton").asCom;
- Tool.Tool2D.Button.addEvent(continueButton, {
- "touchend": () => {
- this.onContinue();
- }
- }, this.fgui.id, 0.9, 0.9, 0, false);
- let quitButton: fgui.GComponent = this.fgui.getChild("quitButton").asCom;
- Tool.Tool2D.Button.addEvent(quitButton, {
- "touchend": () => {
- this.onQuit();
- }
- }, this.fgui.id, 0.9, 0.9, 0, false);
- SDKManager.addButton([
- {
- button: continueButton,
- color: [
- cc.Color.BLACK,
- cc.Color.BLACK,
- ],
- callback: () => {
- if (ConstObject.FirstEnter == false) {
- this.onContinue();
- }
- }
- },
- {
- button: resetButton,
- color: [
- cc.Color.BLACK,
- cc.Color.BLACK,
- ],
- callback: () => {
- if (ConstObject.FirstEnter == false) {
- this.onReset();
- }
- }
- },
- {
- button: quitButton,
- color: [
- cc.Color.BLACK,
- cc.Color.BLACK,
- ],
- callback: () => {
- if (ConstObject.FirstEnter == false) {
- this.onQuit();
- }
- }
- }
- ]);
- EventManager.sendEvent(GameEventName.Music.Music_PauseSound, null);
- if (ConstObject.FirstEnter == true) {
- this.fgui.node.zIndex = -1000;
- // this.onContinue();
- EventManager.onEvent(GameEventName.SDK.SDK_Confirm, this, this.onContinue, 1);
- }
-
- EventManager.sendEvent(GameEventName.View.View_ShowView, HintView);
- }
- protected _refreshView(): void {
- let viewConfig: _IViewConfig = JsonResources.getResources(_EJsonRes.ViewConfig);
- this.fgui.node.zIndex = viewConfig.ZIndex[PauseView.resPath] as any;
- }
- protected _clearView(): void {
- TimeManager.resume();
- SDKManager.removeButton();
- EventManager.sendEvent(GameEventName.Music.Music_ResumeSound, null);
- EventManager.sendEvent(GameEventName.View.View_DestroyView, HintView);
- if (ConstObject.FirstEnter == false) {
- ConstObject.GameState = _ECommonState.Runing;
- }
- }
- protected resize () {
- this.fgui.width = fgui.GRoot.inst.width;
- }
- private onReset (): void {
- ConstObject.GameState = _ECommonState.None;
- EventManager.sendEvent(GameEventName.Music.Music_PlaySound, GameMusicResData.ClickButton);
- EventManager.sendEvent(GameEventName.View.View_DestroyView, PauseView);
- EventManager.sendEvent(GameEventName.View.View_ShowView, GameView);
- GameManager.setGameView(GameEventName.View.View_ShowView);
- }
- private onContinue (): void {
- if (ConstObject.FirstEnter == false) {
- EventManager.sendEvent(GameEventName.Music.Music_PlaySound, GameMusicResData.ClickButton);
- }
- EventManager.sendEvent(GameEventName.View.View_DestroyView, PauseView);
- }
- private onQuit (): void {
- EventManager.sendEvent(GameEventName.Music.Music_PlaySound, GameMusicResData.ClickButton);
-
- EventManager.sendEvent(GameEventName.Game_QuitGame);
- }
- }
|