通用hover效果

This commit is contained in:
2025-05-30 11:52:25 +08:00
parent 6d4bb79a45
commit 23a2f686cb
12 changed files with 395 additions and 122 deletions

View File

@@ -4,16 +4,14 @@ import { DCManager } from "./models/DCManager"
import { LevelManager } from "./models/LevelManager"
import { StorageManager } from "./models/StorageManager"
const { regClass, property } = Laya
const { regClass } = Laya
@regClass()
export class Main extends Laya.Script {
@property(Boolean)
public debug: boolean = false
onAwake() {
console.log("Game onAwake")
config.DEBUG = this.debug
DCManager.getInstance().init()
LevelManager.getInstance().init()
StorageManager.getInstance().init()

View File

@@ -24,15 +24,28 @@ export class UIManager extends Laya.Script {
return UIManager._instance
}
@property(Boolean)
public debug: boolean = false
@property(Laya.Image)
public mask: Laya.Image
@property(Laya.Box)
public btn_clean: Laya.Box
onAwake(): void {
UIManager._instance = this
config.DEBUG = this.debug
this.mask.on(Laya.Event.CLICK, this, () => {
console.log("on click mask >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
})
this.mask.visible = false
this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
console.log("btn_clean=", evt)
StorageManager.getInstance().cleanAll()
})
this.btn_clean.visible = this.debug
}
private UIRoot: Laya.Panel

View File

@@ -42,9 +42,6 @@ export class Home extends Laya.Script {
@property(Laya.Box)
public btn_new_white: Laya.Box
@property(Laya.Box)
public btn_clean: Laya.Box
// 组件被激活后执行,此时所有节点和组件均已创建完毕,此方法只执行一次
onAwake(): void {
const user = StorageManager.getInstance().getUser()
@@ -140,13 +137,6 @@ export class Home extends Laya.Script {
}
}
// 测试逻辑
this.btn_clean.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
console.log("btn_clean=", evt)
StorageManager.getInstance().cleanAll()
})
this.btn_clean.visible = config.DEBUG
// ======
}
public onClickNew(_evt: Laya.Event): void {

View File

@@ -0,0 +1,20 @@
const { regClass, property } = Laya;
@regClass()
export class CommonHover extends Laya.Script {
declare owner : Laya.Box;
onAwake(): void {
this.owner.on(Laya.Event.MOUSE_OVER, this, ()=>{
Laya.Render.canvas.style.cursor = "pointer"
this.owner.alpha = 0.7
})
this.owner.on(Laya.Event.MOUSE_OUT, this, ()=>{
Laya.Render.canvas.style.cursor = ""
this.owner.alpha = 1
})
}
}

View File

@@ -0,0 +1,3 @@
{
"uuid": "a541bdfc-e8e1-4795-b68e-7138c5190f17"
}