重新摆放棋盘

This commit is contained in:
2025-05-29 15:37:45 +08:00
parent 6f3c1f9d6d
commit 4c2915ead8
7 changed files with 83648 additions and 78884 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
{ {
"uuid": "5228993d-78c0-41ae-bd57-ecb0c953ac15" "uuid": "13ccdd2d-0569-4982-8f9e-16edf0ab2f32"
} }

View File

@@ -11,5 +11,6 @@
}, },
"splash": { "splash": {
"fit": "center" "fit": "center"
} },
"stat": true
} }

View File

@@ -6,10 +6,12 @@ Laya.addBeforeInitCallback((stageConfig) => {
if (window.innerWidth > window.innerHeight) { if (window.innerWidth > window.innerHeight) {
stageConfig.designWidth = config.DESIGN_HEIGHT stageConfig.designWidth = config.DESIGN_HEIGHT
stageConfig.designHeight = config.DESIGN_WIDTH stageConfig.designHeight = config.DESIGN_WIDTH
stageConfig.scaleMode = "fixedauto"
config.H_SCREEN = true config.H_SCREEN = true
} else { } else {
stageConfig.designWidth = config.DESIGN_WIDTH stageConfig.designWidth = config.DESIGN_WIDTH
stageConfig.designHeight = config.DESIGN_HEIGHT stageConfig.designHeight = config.DESIGN_HEIGHT
stageConfig.scaleMode = "fixedauto"
config.H_SCREEN = false config.H_SCREEN = false
} }
console.log(`横屏=${config.H_SCREEN}`) console.log(`横屏=${config.H_SCREEN}`)

View File

@@ -6,7 +6,7 @@ const { regClass, property } = Laya
@regClass() @regClass()
export class Block extends Laya.Script { export class Block extends Laya.Script {
declare owner: Laya.Sprite declare owner: Laya.Box
@property(Number) @property(Number)
public XIndex: number = 0 public XIndex: number = 0
@@ -20,39 +20,36 @@ export class Block extends Laya.Script {
@property(Number) @property(Number)
public YGroup: number = 0 public YGroup: number = 0
private tips_bgs: Array<Laya.Sprite> = [] private sprite_show: Laya.Sprite
private label_show: Laya.Label private label_show: Laya.Label
private tips_bgs: Array<Laya.Sprite> = []
private tips_labels: Array<Laya.Label> = [] private tips_labels: Array<Laya.Label> = []
private selected: boolean = false private selected: boolean = false
private data: DOBlock private data: DOBlock
public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void { public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, handler: any, func: any): void {
this.XIndex = XIndex this.XIndex = XIndex
this.YIndex = YIndex this.YIndex = YIndex
this.XGroup = XGroup this.XGroup = XGroup
this.YGroup = YGroup this.YGroup = YGroup
let VBox = this.owner.getChildByName("VBox") this.sprite_show = this.owner.getChildByName("Sprite") as Laya.Sprite
for (let i = 0; i < VBox.numChildren; i++) { this.label_show = this.owner.getChildByName("label_show") as Laya.Label
const hbox = VBox.getChildAt(i)
let notes = this.owner.getChildByName("notes")
for (let i = 0; i < notes.numChildren; i++) {
const hbox = notes.getChildAt(i)
for (let j = 0; j < hbox.numChildren; j++) { for (let j = 0; j < hbox.numChildren; j++) {
const sp = hbox.getChildAt(j) as Laya.Sprite const sp = hbox.getChildAt(j).getChildByName("Sprite") as Laya.Sprite
this.tips_bgs.push(sp) this.tips_bgs.push(sp)
} const Label = hbox.getChildAt(j).getChildByName("Label") as Laya.Label
}
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
// this.label_show.text = XGroup + "" + YGroup
VBox = label_obj.getChildByName("VBox")
for (let i = 0; i < VBox.numChildren; i++) {
const hbox = VBox.getChildAt(i)
for (let j = 0; j < hbox.numChildren; j++) {
const Label = hbox.getChildAt(j) as Laya.Label
Label.text = "" Label.text = ""
this.tips_labels.push(Label) this.tips_labels.push(Label)
} }
} }
this.owner.on(Laya.Event.CLICK, handler, func) this.owner.on(Laya.Event.CLICK, handler, func)
} }
@@ -62,22 +59,22 @@ export class Block extends Laya.Script {
} }
public setBlockColor(color: string, alpha: number = 1, animated: boolean = false, completedColor: string = "", completedAlpha: number = 1): void { public setBlockColor(color: string, alpha: number = 1, animated: boolean = false, completedColor: string = "", completedAlpha: number = 1): void {
let blockSize = 116 let blockSize = 112
if (config.H_SCREEN) if (config.H_SCREEN)
blockSize = 96 blockSize = 90
this.owner.graphics.clear() this.sprite_show.graphics.clear()
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, color) this.sprite_show.graphics.drawRect(0, 0, blockSize, blockSize, color)
if (animated) { if (animated) {
this.owner.alpha = 0 this.sprite_show.alpha = 0
Laya.Tween.to(this.owner, { alpha }, 100, Laya.Ease.linearIn) Laya.Tween.to(this.sprite_show, { alpha }, 100, Laya.Ease.linearIn)
Laya.Tween.to(this.owner, { alpha: 0 }, 150, Laya.Ease.linearIn, null, 100) Laya.Tween.to(this.sprite_show, { alpha: 0 }, 150, Laya.Ease.linearIn, null, 100)
Laya.Tween.to(this.owner, { alpha }, 100, Laya.Ease.linearIn, Laya.Handler.create(this, () => { Laya.Tween.to(this.sprite_show, { alpha }, 100, Laya.Ease.linearIn, Laya.Handler.create(this, () => {
this.owner.graphics.clear() this.sprite_show.graphics.clear()
this.owner.graphics.drawRect(0, 0, blockSize, blockSize, completedColor) this.sprite_show.graphics.drawRect(0, 0, blockSize, blockSize, completedColor)
this.owner.alpha = completedAlpha this.sprite_show.alpha = completedAlpha
}), 250) }), 250)
} else { } else {
this.owner.alpha = alpha this.sprite_show.alpha = alpha
} }
} }
@@ -97,7 +94,7 @@ export class Block extends Laya.Script {
} }
public setTipsBgColor(visible: boolean, noteNumber: number = 0, color: string = "", alpha: number = 1): void { public setTipsBgColor(visible: boolean, noteNumber: number = 0, color: string = "", alpha: number = 1): void {
let blockSize = 38 let blockSize = 37
if (config.H_SCREEN) if (config.H_SCREEN)
blockSize = 30 blockSize = 30
if (visible) { if (visible) {
@@ -128,7 +125,7 @@ export class Block extends Laya.Script {
if (this.data.get_checked()) { if (this.data.get_checked()) {
this.data.set_score(score) this.data.set_score(score)
if (score > 0) if (score > 0)
G_ShowScoreTips(score.toString(), this.label_show.parent) G_ShowScoreTips(score.toString(), this.owner)
} else { } else {
if (this.data.get_score() !== 0) if (this.data.get_score() !== 0)
this.data.set_score(0) this.data.set_score(0)

View File

@@ -42,9 +42,6 @@ export class Stage extends Laya.Script {
@property(Laya.Box) @property(Laya.Box)
public obj_blocks: Laya.Box public obj_blocks: Laya.Box
@property(Laya.Box)
public obj_block_labels: Laya.Box
private blocks: Array<Block> = [] private blocks: Array<Block> = []
@property(Laya.Box) @property(Laya.Box)
@@ -104,24 +101,26 @@ export class Stage extends Laya.Script {
this.btn_pause.on(Laya.Event.CLICK, this, () => { this.btn_pause.on(Laya.Event.CLICK, this, () => {
UIManager.getInstance().loadGamePauseUI(this.data) UIManager.getInstance().loadGamePauseUI(this.data)
}) })
for (let i = 0; i < this.obj_blocks.numChildren; i++) {
const hbox = this.obj_blocks.getChildAt(i)
const l_hbox = this.obj_block_labels.getChildAt(i)
for (let j = 0; j < hbox.numChildren; j++) {
const block = hbox.getChildAt(j).getComponent(Block)
this.blocks.push(block)
let XGroup = 0 let XGroup = 0
if (j === 3 || j === 4 || j === 5)
XGroup = 1
if (j === 6 || j === 7 || j === 8)
XGroup = 2
let YGroup = 0 let YGroup = 0
if (i === 3 || i === 4 || i === 5) for (let i = 0; i < this.obj_blocks.numChildren; i++) {
YGroup = 1 YGroup = i
if (i === 6 || i === 7 || i === 8) const ibox = this.obj_blocks.getChildAt(i)
YGroup = 2 for (let j = 0; j < ibox.numChildren; j++) {
const l_vbox = l_hbox.getChildAt(j) as Laya.Box XGroup = j
block.onInit(j, i, XGroup, YGroup, l_vbox, this, this.onClickBlock) const jbox = ibox.getChildAt(j)
const VBox = jbox.getChildByName("VBox")
for (let k = 0; k < VBox.numChildren; k++) {
const kbox = VBox.getChildAt(k)
for (let l = 0; l < kbox.numChildren; l++) {
const block = kbox.getChildAt(l).getComponent(Block)
this.blocks.push(block)
const XIndex = j * 3 + l
const YIndex = i * 3 + k
block.onInit(XIndex, YIndex, XGroup, YGroup, this, this.onClickBlock)
}
}
} }
} }
for (let i = 0; i < this.obj_candys.numChildren; i++) { for (let i = 0; i < this.obj_candys.numChildren; i++) {