重新摆放棋盘

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

View File

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