优化hover效果

This commit is contained in:
2025-05-30 16:43:00 +08:00
parent 73342c1f77
commit 84d1ac4798
9 changed files with 132 additions and 65 deletions

View File

@@ -4,15 +4,22 @@ const { regClass, property } = Laya;
export class CommonHover extends Laya.Script {
declare owner : Laya.Box;
@property(Boolean)
public hoverAlpha: boolean = true
onAwake(): void {
this.owner.on(Laya.Event.MOUSE_OVER, this, ()=>{
Laya.Render.canvas.style.cursor = "pointer"
this.owner.alpha = 0.7
if (this.hoverAlpha) {
this.owner.alpha = 0.7
}
})
this.owner.on(Laya.Event.MOUSE_OUT, this, ()=>{
Laya.Render.canvas.style.cursor = ""
this.owner.alpha = 1
if (this.hoverAlpha) {
this.owner.alpha = 1
}
})
}