Files
sudoku/src/views/common/CommonHover.ts

25 lines
557 B
TypeScript
Raw Normal View History

2025-05-30 16:52:51 +08:00
const { regClass, property } = Laya
2025-05-30 11:52:25 +08:00
@regClass()
export class CommonHover extends Laya.Script {
2025-05-30 16:52:51 +08:00
declare owner: Laya.Box
2025-05-30 11:52:25 +08:00
2025-05-30 16:52:51 +08:00
@property(Boolean)
public hoverAlpha: boolean = true
2025-05-30 16:43:00 +08:00
2025-05-30 16:52:51 +08:00
onAwake(): void {
this.owner.on(Laya.Event.MOUSE_OVER, this, () => {
Laya.Render.canvas.style.cursor = "pointer"
if (this.hoverAlpha) {
this.owner.alpha = 0.7
}
})
this.owner.on(Laya.Event.MOUSE_OUT, this, () => {
Laya.Render.canvas.style.cursor = ""
if (this.hoverAlpha) {
this.owner.alpha = 1
}
})
}
}