添加背景动画

This commit is contained in:
2025-06-19 20:12:34 +08:00
parent cbef3f7cd8
commit ea0e00f495

View File

@@ -1,4 +1,5 @@
import { config } from "../constants/config" import { config } from "../constants/config"
import { Utility_EaseOut, Utility_EaseOut_2 } from "../utils/utility"
import { CommonData } from "./common/CommonData" import { CommonData } from "./common/CommonData"
const { regClass, property } = Laya const { regClass, property } = Laya
@@ -10,9 +11,14 @@ export class Difficulty extends Laya.Script {
@property(Laya.Box) @property(Laya.Box)
public obj_items: Laya.Box public obj_items: Laya.Box
private mask: Laya.Image
private offset: Laya.Box private offset: Laya.Box
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void { onAwake(): void {
this.mask = this.owner.getChildByName("mask") as Laya.Image
this.mask.alpha = 0
Laya.Tween.to(this.mask, { alpha: 0.4 }, 400, Utility_EaseOut)
this.offset = this.owner.getChildByName("bottom").getChildByName("offset") as Laya.Box this.offset = this.owner.getChildByName("bottom").getChildByName("offset") as Laya.Box
this.offset.y = this.offset.width this.offset.y = this.offset.width
@@ -23,11 +29,17 @@ export class Difficulty extends Laya.Script {
const mask = this.owner.getChildByName("mask") const mask = this.owner.getChildByName("mask")
mask.on(Laya.Event.CLICK, this, () => { mask.on(Laya.Event.CLICK, this, () => {
Laya.Tween.to(this.offset, { y: 2400 }, 200, null, Laya.Handler.create(this, () => { Laya.Tween.to(this.offset, { y: 2400 }, 200, null, Laya.Handler.create(this, () => {
this.owner.destroy() this.destroyUI()
})) }))
}) })
} }
destroyUI(): void {
Laya.Tween.to(this.mask, { alpha: 0 }, 400, Utility_EaseOut_2, Laya.Handler.create(this, () => {
this.owner.destroy()
}))
}
onStart(): void { onStart(): void {
Laya.Tween.to(this.offset, { y: 0 }, 200) Laya.Tween.to(this.offset, { y: 0 }, 200)
} }