调整核心玩法细节表现
This commit is contained in:
@@ -5,7 +5,7 @@ const { regClass, property } = Laya;
|
||||
|
||||
@regClass()
|
||||
export class Block extends Laya.Script {
|
||||
declare owner : Laya.Button;
|
||||
declare owner : Laya.Sprite;
|
||||
|
||||
@property(Number)
|
||||
public XIndex: number = 0;
|
||||
@@ -16,23 +16,32 @@ export class Block extends Laya.Script {
|
||||
@property(Number)
|
||||
public YGroup: number = 0;
|
||||
|
||||
private tips_bgs: Array<Laya.Sprite> = new Array();
|
||||
private label_show: Laya.Label;
|
||||
private tips_labels: Array<Laya.Label> = new Array();
|
||||
private animator: Laya.Animator2D
|
||||
|
||||
private selected: boolean = false
|
||||
private newSelect: boolean = false
|
||||
|
||||
private data: DOBlock
|
||||
|
||||
|
||||
public onInit(XIndex: number, YIndex: number, XGroup: number, YGroup: number, label_obj: Laya.Box, handler: any, func: any): void {
|
||||
this.XIndex = XIndex;
|
||||
this.YIndex = YIndex;
|
||||
this.XGroup = XGroup;
|
||||
this.YGroup = YGroup;
|
||||
|
||||
var VBox = this.owner.getChildByName("VBox")
|
||||
for (var i=0; i<VBox.numChildren; i++) {
|
||||
var hbox = VBox.getChildAt(i)
|
||||
for (var j=0; j<hbox.numChildren; j++) {
|
||||
var sp = hbox.getChildAt(j) as Laya.Sprite
|
||||
this.tips_bgs.push(sp)
|
||||
}
|
||||
}
|
||||
this.label_show = label_obj.getChildByName("label_show") as Laya.Label
|
||||
var VBox = label_obj.getChildByName("VBox")
|
||||
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++) {
|
||||
@@ -42,7 +51,6 @@ export class Block extends Laya.Script {
|
||||
}
|
||||
}
|
||||
this.owner.on(Laya.Event.CLICK, handler, func);
|
||||
this.animator = this.owner.getComponent(Laya.Animator2D)
|
||||
}
|
||||
|
||||
public setSelected(selected: boolean): void {
|
||||
@@ -52,16 +60,52 @@ export class Block extends Laya.Script {
|
||||
this.updateBlock()
|
||||
}
|
||||
|
||||
public setButtonSkin(skin: string): void {
|
||||
this.owner.skin = skin
|
||||
public setBlockColor(color: string, alpha: number=1, animated: boolean=false, completedColor: string = "", completedAlpha: number=1): void {
|
||||
this.owner.graphics.clear()
|
||||
this.owner.graphics.drawRect(0, 0, 116, 116, color)
|
||||
if (animated) {
|
||||
Laya.Tween.to(this.owner, {alpha:alpha}, 500, Laya.Ease.elasticOut, Laya.Handler.create(this, () => {
|
||||
this.owner.graphics.clear()
|
||||
this.owner.graphics.drawRect(0, 0, 116, 116, completedColor)
|
||||
this.owner.alpha = completedAlpha
|
||||
}))
|
||||
}
|
||||
else {
|
||||
this.owner.alpha = alpha
|
||||
}
|
||||
}
|
||||
|
||||
public setFadeAnimation(): void {
|
||||
if (this.animator) {
|
||||
this.animator.play("fade_to_red")
|
||||
Laya.timer.frameOnce(40, this, ()=>{
|
||||
this.animator.stop()
|
||||
})
|
||||
var color = this.label_show.color
|
||||
var flag = true
|
||||
Laya.timer.loop(200, this, ()=>{
|
||||
flag = !flag
|
||||
if (flag) {
|
||||
this.label_show.color = color
|
||||
}
|
||||
else {
|
||||
this.label_show.color = "#ff0000"
|
||||
}
|
||||
})
|
||||
Laya.Tween.to(this.label_show, {color:"#ff0000"}, 1000, Laya.Ease.strongIn, Laya.Handler.create(this, () => {
|
||||
this.label_show.color = color
|
||||
Laya.timer.clearAll(this)
|
||||
}))
|
||||
}
|
||||
|
||||
public setTipsBgColor(visible: boolean, noteNumber: number=0, color: string="", alpha: number=1): void {
|
||||
if (visible) {
|
||||
var obj = this.tips_bgs[noteNumber-1]
|
||||
obj.visible = true
|
||||
obj.graphics.clear()
|
||||
obj.graphics.drawRect(0, 0, 38, 38, color)
|
||||
obj.alpha = alpha
|
||||
}
|
||||
else {
|
||||
for (var i=0; i<this.tips_bgs.length; i++) {
|
||||
var obj = this.tips_bgs[i]
|
||||
obj.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,31 +126,59 @@ export class Block extends Laya.Script {
|
||||
if (this.data.get_checked()) {
|
||||
score = 150
|
||||
this.data.set_score(score)
|
||||
G_ShowScoreTips(score.toString(), this.owner)
|
||||
G_ShowScoreTips(score.toString(), this.label_show)
|
||||
}
|
||||
}
|
||||
this.data.clean_notes()
|
||||
this.updateBlock()
|
||||
}
|
||||
return this.data.get_checked()
|
||||
}
|
||||
|
||||
public addNoteNumber(noteNumber: number): void {
|
||||
if (this.data.add_note(noteNumber)) {
|
||||
this.updateBlock()
|
||||
this.data.set_show(0)
|
||||
var note_numbers = this.data.get_notes()
|
||||
var find = note_numbers.indexOf(noteNumber)
|
||||
|
||||
if (find >= 0) {
|
||||
this.data.remove_note(noteNumber)
|
||||
}
|
||||
else {
|
||||
this.data.add_note(noteNumber)
|
||||
}
|
||||
this.updateBlock()
|
||||
}
|
||||
|
||||
updateBlock(): void {
|
||||
for (var i=0; i<this.tips_labels.length; i++)
|
||||
this.tips_labels[i].text = ""
|
||||
if (this.data.get_show() > 0) {
|
||||
this.label_show.text = this.data.get_show().toString()
|
||||
if (this.data.get_checked()) {
|
||||
this.label_show.color = "#000000"
|
||||
//设置文字颜色
|
||||
if (this.selected) {
|
||||
this.label_show.color = "#ffffff"
|
||||
for (var i=0; i<this.tips_labels.length; i++) {
|
||||
this.tips_labels[i].color = "#ffffff"
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.data.get_show() == this.data.get_correct()) {
|
||||
if (this.data.get_preset()) {
|
||||
this.label_show.color = "#2d3138"
|
||||
}
|
||||
else {
|
||||
this.label_show.color = "#2559c0"
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.label_show.color = "#ff0000"
|
||||
this.label_show.color = "#cb3256"
|
||||
}
|
||||
for (var i=0; i<this.tips_labels.length; i++) {
|
||||
this.tips_labels[i].color = "#2d3138"
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=0; i<this.tips_labels.length; i++) {
|
||||
this.tips_labels[i].text = ""
|
||||
}
|
||||
if (this.data.get_show() > 0) {
|
||||
this.label_show.text = this.data.get_show().toString()
|
||||
}
|
||||
else {
|
||||
this.label_show.text = "";
|
||||
@@ -115,12 +187,6 @@ export class Block extends Laya.Script {
|
||||
var value = note_numbers[i]
|
||||
var label = this.tips_labels[value-1]
|
||||
label.text = value.toString()
|
||||
if (this.selected) {
|
||||
label.color = "#ffffff"
|
||||
}
|
||||
else {
|
||||
label.color = "#000000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user