优化棋盘表现问题
This commit is contained in:
@@ -21,9 +21,11 @@ export class Block extends Laya.Script {
|
||||
public YGroup: number = 0
|
||||
|
||||
private sprite_show: Laya.Sprite
|
||||
private blockSize: number
|
||||
private label_show: Laya.Label
|
||||
private tips_bgs: Array<Laya.Sprite> = []
|
||||
private tips_labels: Array<Laya.Label> = []
|
||||
private tipsSize: number
|
||||
|
||||
private selected: boolean = false
|
||||
|
||||
@@ -36,6 +38,7 @@ export class Block extends Laya.Script {
|
||||
this.YGroup = YGroup
|
||||
|
||||
this.sprite_show = this.owner.getChildByName("Sprite") as Laya.Sprite
|
||||
this.blockSize = this.sprite_show.width
|
||||
this.label_show = this.owner.getChildByName("label_show") as Laya.Label
|
||||
|
||||
const notes = this.owner.getChildByName("notes")
|
||||
@@ -47,6 +50,7 @@ export class Block extends Laya.Script {
|
||||
const Label = hbox.getChildAt(j).getChildByName("Label") as Laya.Label
|
||||
Label.text = ""
|
||||
this.tips_labels.push(Label)
|
||||
this.tipsSize = sp.width
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,18 +63,15 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
|
||||
public setBlockColor(color: string, alpha: number = 1, animated: boolean = false, completedColor: string = "", completedAlpha: number = 1): void {
|
||||
let blockSize = 112
|
||||
if (config.H_SCREEN)
|
||||
blockSize = 90
|
||||
this.sprite_show.graphics.clear()
|
||||
this.sprite_show.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
||||
this.sprite_show.graphics.drawRect(0, 0, this.blockSize, this.blockSize, color)
|
||||
if (animated) {
|
||||
this.sprite_show.alpha = 0
|
||||
Laya.Tween.to(this.sprite_show, { alpha }, 200, Laya.Ease.linearIn)
|
||||
Laya.Tween.to(this.sprite_show, { alpha: 0 }, 300, Laya.Ease.linearIn, null, 200)
|
||||
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.graphics.drawRect(0, 0, this.blockSize, this.blockSize, completedColor)
|
||||
this.sprite_show.alpha = completedAlpha
|
||||
}), 500)
|
||||
} else {
|
||||
@@ -94,14 +95,11 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
|
||||
public setTipsBgColor(visible: boolean, noteNumber: number = 0, color: string = "", alpha: number = 1): void {
|
||||
let blockSize = 37
|
||||
if (config.H_SCREEN)
|
||||
blockSize = 30
|
||||
if (visible) {
|
||||
const obj = this.tips_bgs[noteNumber - 1]
|
||||
obj.visible = true
|
||||
obj.graphics.clear()
|
||||
obj.graphics.drawRect(0, 0, blockSize, blockSize, color)
|
||||
obj.graphics.drawRect(0, 0, this.tipsSize, this.tipsSize, color)
|
||||
obj.alpha = alpha
|
||||
} else {
|
||||
for (let i = 0; i < this.tips_bgs.length; i++) {
|
||||
@@ -125,7 +123,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.owner)
|
||||
G_ShowScoreTips(`+${score}`, this.owner)
|
||||
} else {
|
||||
if (this.data.get_score() !== 0)
|
||||
this.data.set_score(0)
|
||||
|
||||
Reference in New Issue
Block a user