整理层级

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

@@ -1,17 +1,17 @@
import { config } from "./constants/config"
Laya.addBeforeInitCallback((stageConfig) => {
const { breakpoint } = config
if (window.innerWidth / window.innerHeight <= breakpoint) {
stageConfig.designWidth = 1080
stageConfig.designHeight = 1920
stageConfig.scaleMode = "fixedwidth"
}
else {
stageConfig.designWidth = 1920
stageConfig.designHeight = 1080
stageConfig.scaleMode = "fixedauto"
}
// const { breakpoint } = config
// if (window.innerWidth / window.innerHeight <= breakpoint) {
// stageConfig.designWidth = 1080
// stageConfig.designHeight = 1920
// stageConfig.scaleMode = "fixedwidth"
// }
// else {
// stageConfig.designWidth = 1920
// stageConfig.designHeight = 1080
// stageConfig.scaleMode = "fixedauto"
// }
})
export async function main() {

View File

@@ -11,6 +11,7 @@ export class UIManager extends Laya.Script {
private static _instance: UIManager
onAwake(): void {
UIManager._instance = this
this.stage.owner.visible = false
}
public static getInstance(): UIManager {
@@ -18,6 +19,7 @@ export class UIManager extends Laya.Script {
}
public loadStage(): void {
this.stage.owner.visible = true
this.stage.onLoadStage("aBCeIGFhdEDFcAHBGIhigBdfecAgHDiFBCaeBEAGHCIdffcIdEAHbgcABfGEdiHIFHaCDGEBDGEHbiaFC");
}

View File

@@ -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 = "";
}
}

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 = ""
}
}
}

View File

@@ -13,10 +13,14 @@ export class Stage extends Laya.Script {
@property(Laya.Box)
public obj_blocks: Laya.Box;
@property(Laya.Box)
public obj_block_labels: Laya.Box;
private blocks: Array<Block> = new Array();
@property(Laya.Box)
public obj_candys: Laya.Box;
@property(Laya.Box)
public obj_candy_labels: Laya.Box;
private candys: Array<Candy> = new Array();
@property(Laya.Box)
@@ -63,6 +67,7 @@ export class Stage extends Laya.Script {
for (var i=0; i<this.obj_blocks.numChildren; i++) {
var hbox = this.obj_blocks.getChildAt(i);
var l_hbox = this.obj_block_labels.getChildAt(i);
for (var j=0; j<hbox.numChildren; j++) {
var block = hbox.getChildAt(j).getComponent(Block);
this.blocks.push(block);
@@ -76,13 +81,15 @@ export class Stage extends Laya.Script {
YGroup = 1
if (j==6 || j==7 || j==8)
YGroup = 2
block.onInit(i, j, XGroup, YGroup, this, this.onClickBlock)
var l_vbox = l_hbox.getChildAt(j) as Laya.Box
block.onInit(l_vbox, i, j, XGroup, YGroup, this, this.onClickBlock)
}
}
for (var i=0; i<this.obj_candys.numChildren; i++) {
var candy = this.obj_candys.getChildAt(i).getComponent(Candy);
this.candys.push(candy);
candy.onInit(i+1, this, this.onClickCandy)
var box = this.obj_candy_labels.getChildAt(i) as Laya.Box
candy.onInit(box, i+1, this, this.onClickCandy)
}
this.obj_block_colors.visible = false