整理层级

This commit is contained in:
2025-05-12 10:43:02 +08:00
parent cacd1c2574
commit 45d7df0184
9 changed files with 17567 additions and 792 deletions

View File

@@ -4,13 +4,15 @@ const { regClass, property } = Laya;
export class Candy extends Laya.Script {
declare owner : Laya.Button;
@property(Laya.Label)
public label_left: Laya.Label;
private label_show: Laya.Label;
private label_left: Laya.Label;
private showNumber: number = 0;
private left: number = 0;
public onInit(showNumber: number, handler: any, func: any): void {
public onInit(label_obj: Laya.Box, showNumber: number, handler: any, func: any): void {
this.label_show = label_obj.getChildByName("label") as Laya.Label
this.label_left = label_obj.getChildByName("label_left") as Laya.Label
this.showNumber = showNumber
this.owner.on(Laya.Event.CLICK, handler, func)
this.updateCandy()
@@ -31,7 +33,17 @@ export class Candy extends Laya.Script {
updateCandy(): void {
this.owner.active = this.left > 0
this.owner.label = this.showNumber.toString();
this.label_left.text = this.left.toString();
if (this.showNumber > 0) {
this.label_show.text = this.showNumber.toString();
}
else {
this.label_show.text = ""
}
if (this.left > 0) {
this.label_left.text = this.left.toString();
}
else {
this.label_left.text = ""
}
}
}