整理层级
This commit is contained in:
@@ -4,6 +4,9 @@ const { regClass, property } = Laya;
|
||||
export class Block extends Laya.Script {
|
||||
declare owner : Laya.Button;
|
||||
|
||||
private label_show: Laya.Label;
|
||||
private tips_labels: Array<Laya.Label> = new Array();
|
||||
|
||||
@property(Number)
|
||||
public XIndex: number = 0;
|
||||
@property(Number)
|
||||
@@ -18,7 +21,17 @@ export class Block extends Laya.Script {
|
||||
private showNumber: number = 0;
|
||||
private correctNumber: number = 0;
|
||||
|
||||
public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, handler: any, func: any): void {
|
||||
public onInit(label_obj: Laya.Box, XIndex: number, YIndex: number, XGroup: number, YGroup: number, handler: any, func: any): void {
|
||||
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
|
||||
var VBox = label_obj.getChildByName("VBox")
|
||||
for (var i=0; i<VBox.numChildren; i++) {
|
||||
var hbox = VBox.getChildAt(i);
|
||||
for (var j=0; j<hbox.numChildren; j++) {
|
||||
var Label = hbox.getChildAt(j) as Laya.Label
|
||||
Label.text = ""
|
||||
this.tips_labels.push(Label)
|
||||
}
|
||||
}
|
||||
this.XIndex = XIndex;
|
||||
this.YIndex = YIndex;
|
||||
this.XGroup = XGroup;
|
||||
@@ -63,14 +76,16 @@ export class Block extends Laya.Script {
|
||||
|
||||
updateBlock(): void {
|
||||
if (this.showNumber > 0) {
|
||||
this.owner.label = this.showNumber.toString();
|
||||
if (this.checked)
|
||||
this.owner.labelColors = "#000000,#000000,#000000"
|
||||
else
|
||||
this.owner.labelColors = "#ff0000,#ff0000,#ff0000"
|
||||
this.label_show.text = this.showNumber.toString();
|
||||
if (this.checked) {
|
||||
this.label_show.color = "#000000"
|
||||
}
|
||||
else {
|
||||
this.label_show.color = "#ff0000"
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.owner.label = "";
|
||||
this.label_show.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user