重新摆放棋盘
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"uuid": "5228993d-78c0-41ae-bd57-ecb0c953ac15"
|
||||
"uuid": "13ccdd2d-0569-4982-8f9e-16edf0ab2f32"
|
||||
}
|
||||
@@ -11,5 +11,6 @@
|
||||
},
|
||||
"splash": {
|
||||
"fit": "center"
|
||||
}
|
||||
},
|
||||
"stat": true
|
||||
}
|
||||
@@ -6,10 +6,12 @@ Laya.addBeforeInitCallback((stageConfig) => {
|
||||
if (window.innerWidth > window.innerHeight) {
|
||||
stageConfig.designWidth = config.DESIGN_HEIGHT
|
||||
stageConfig.designHeight = config.DESIGN_WIDTH
|
||||
stageConfig.scaleMode = "fixedauto"
|
||||
config.H_SCREEN = true
|
||||
} else {
|
||||
stageConfig.designWidth = config.DESIGN_WIDTH
|
||||
stageConfig.designHeight = config.DESIGN_HEIGHT
|
||||
stageConfig.scaleMode = "fixedauto"
|
||||
config.H_SCREEN = false
|
||||
}
|
||||
console.log(`横屏=${config.H_SCREEN}`)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -42,9 +42,6 @@ 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> = []
|
||||
|
||||
@property(Laya.Box)
|
||||
@@ -104,24 +101,26 @@ export class Stage extends Laya.Script {
|
||||
this.btn_pause.on(Laya.Event.CLICK, this, () => {
|
||||
UIManager.getInstance().loadGamePauseUI(this.data)
|
||||
})
|
||||
|
||||
let XGroup = 0
|
||||
let YGroup = 0
|
||||
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
|
||||
if (j === 3 || j === 4 || j === 5)
|
||||
XGroup = 1
|
||||
if (j === 6 || j === 7 || j === 8)
|
||||
XGroup = 2
|
||||
let YGroup = 0
|
||||
if (i === 3 || i === 4 || i === 5)
|
||||
YGroup = 1
|
||||
if (i === 6 || i === 7 || i === 8)
|
||||
YGroup = 2
|
||||
const l_vbox = l_hbox.getChildAt(j) as Laya.Box
|
||||
block.onInit(j, i, XGroup, YGroup, l_vbox, this, this.onClickBlock)
|
||||
YGroup = i
|
||||
const ibox = this.obj_blocks.getChildAt(i)
|
||||
for (let j = 0; j < ibox.numChildren; j++) {
|
||||
XGroup = j
|
||||
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++) {
|
||||
|
||||
Reference in New Issue
Block a user