添加弹窗动画

This commit is contained in:
2025-06-06 16:05:54 +08:00
parent 27f5716dcc
commit d6acd97396
11 changed files with 149 additions and 44 deletions

View File

@@ -6,6 +6,7 @@ import { StorageManager } from "../models/StorageManager"
import { UIManager } from "../models/UIManager"
import { Difficulty } from "./Difficulty"
import { ResourceManager } from "../models/ResourceManager"
import { Utility_EaseOut, Utility_EaseOut_2 } from "../utils/utility"
const { regClass, property } = Laya
@@ -25,11 +26,36 @@ export class GameOver extends Laya.Script {
@property(Laya.Label)
public label_newOrClose: Laya.Label
private mask: Laya.Image
private center: Laya.Box
onAwake(): void {
this.mask = this.owner.getChildByName("Image") as Laya.Image
this.mask.alpha = 0
Laya.Tween.to(this.mask, {alpha: 0.6}, 400, Utility_EaseOut)
this.center = this.owner.getChildByName("center") as Laya.Box
this.center.scaleX = 0.8
this.center.scaleY = 0.8
Laya.Tween.to(this.center, {scaleX: 1, scaleY: 1}, 400, Utility_EaseOut)
this.center.alpha = 0
Laya.Tween.to(this.center, {alpha: 1}, 400, Utility_EaseOut)
}
destroyUI(): void {
Laya.Tween.to(this.mask, {alpha: 0}, 400, Utility_EaseOut_2)
Laya.Tween.to(this.center, {scaleX: 0.8, scaleY: 0.8}, 400, Utility_EaseOut_2)
Laya.Tween.to(this.center, {alpha: 0}, 400, Utility_EaseOut_2, Laya.Handler.create(this, () => {
this.owner.destroy()
}))
}
public onSetStageInfo(doStage: DOStage): void {
this.btn_second.on(Laya.Event.CLICK, this, () => {
doStage.set_mistake(doStage.get_mistake() - 1)
EventManager.getInstance().DispatchEvent(EVENT_TYPES.NOT_UPDATE_MISTAKE)
this.owner.destroy()
this.destroyUI()
})
this.btn_restart.on(Laya.Event.CLICK, this, () => {
@@ -38,7 +64,7 @@ export class GameOver extends Laya.Script {
const difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(stageID, type, difficulty, difficulty)
UIManager.getInstance().loadStageUI(stageID)
this.owner.destroy()
this.destroyUI()
})
const type = doStage.get_stageType()
@@ -51,7 +77,7 @@ export class GameOver extends Laya.Script {
const difficulty = doStage.get_difficulty()
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, difficulty, difficulty)
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
this.owner.destroy()
this.destroyUI()
} else {
ResourceManager.getInstance().loadPrefab(respath.difficulty_ui_res, (go: any)=> {
const prefab = go.create()
@@ -60,7 +86,7 @@ export class GameOver extends Laya.Script {
console.log("选择难度", value)
StorageManager.getInstance().newStage(config.DEFAULT_STAGE_ID, config.STAGE_TYPE.MAIN, value, value)
UIManager.getInstance().loadStageUI(config.DEFAULT_STAGE_ID)
this.owner.destroy()
this.destroyUI()
})
})
}
@@ -70,7 +96,7 @@ export class GameOver extends Laya.Script {
this.btn_newOrClose.on(Laya.Event.CLICK, this, () => {
UIManager.getInstance().loadDCUI()
UIManager.getInstance().closeStageUI()
this.owner.destroy()
this.destroyUI()
})
}
}