game pause
This commit is contained in:
52
src/views/GamePause.ts
Normal file
52
src/views/GamePause.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
import { UIManager } from "../models/UIManager";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { EVENT_TYPES, EventManager } from "../models/EventManager";
|
||||
|
||||
|
||||
|
||||
const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class GamePause extends Laya.Script {
|
||||
declare owner : Laya.Box;
|
||||
|
||||
@property(Laya.Label)
|
||||
public label_time: Laya.Label
|
||||
@property(Laya.Label)
|
||||
public label_diffucuty: Laya.Label
|
||||
|
||||
@property(Laya.Sprite)
|
||||
public btn_continue: Laya.Sprite
|
||||
@property(Laya.Sprite)
|
||||
public btn_restart: Laya.Sprite
|
||||
|
||||
|
||||
//组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
|
||||
onAwake(): void {
|
||||
|
||||
var doStage = StorageManager.getInstance().getStage()
|
||||
|
||||
this.label_time.text = Utility_ConvertSecondToString(doStage.get_duration())
|
||||
this.label_diffucuty.text = doStage.get_difficulty()
|
||||
|
||||
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, true)
|
||||
this.btn_continue.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_PAUSE, false)
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
this.btn_restart.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
|
||||
var stageID = doStage.get_stageID()
|
||||
var type = doStage.get_stageType()
|
||||
var difficulty = doStage.get_difficulty()
|
||||
StorageManager.getInstance().cleanStage()
|
||||
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
|
||||
UIManager.getInstance().loadStageUI(stageID);
|
||||
this.owner.destroy()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user