按钮文本对齐

This commit is contained in:
2025-06-17 18:55:47 +08:00
parent e61043dfaa
commit d27fa03b13
2 changed files with 30 additions and 17 deletions

View File

@@ -425,33 +425,42 @@
"valign": "middle"
},
{
"_$id": "pr17wcli",
"_$type": "Image",
"name": "time",
"x": 267,
"_$id": "8gztmoqm",
"_$type": "HBox",
"name": "HBox",
"x": 269,
"y": 107,
"width": 35,
"width": 254,
"height": 35,
"centerX": -112,
"centerX": 0,
"centerY": 40,
"skin": "res://2b4d26c7-ae87-47a3-8084-29a243441634",
"useSourceSize": true,
"color": "#ffffff",
"space": 16,
"align": "middle",
"_$child": [
{
"_$id": "2l5pfddm",
"_$type": "Label",
"_$id": "pr17wcli",
"_$type": "Image",
"name": "time",
"width": 35,
"height": 35,
"skin": "res://2b4d26c7-ae87-47a3-8084-29a243441634",
"useSourceSize": true,
"color": "#ffffff"
},
{
"_$id": "mx9od6cw",
"_$type": "Text",
"name": "label_time",
"x": 51,
"width": 400,
"height": 35,
"y": 4,
"width": 203,
"height": 28,
"alpha": 0.6,
"text": "00:00-Hard",
"font": "res://83c7971a-e73f-40ba-92a8-7d6fccac0958",
"fontSize": 36,
"color": "rgba(255, 255, 255, 0.6078431372549019)",
"bold": true,
"valign": "middle"
"color": "#ffffff",
"leading": 2
}
]
}

View File

@@ -124,10 +124,14 @@ export class Home extends Laya.Script {
this.btn_new_white.visible = true
this.btn_go.visible = true
const label_time = this.btn_go.getChildByName("time").getChildByName("label_time") as Laya.Label
const HBox = this.btn_go.getChildByName("HBox") as Laya.HBox
const time = HBox.getChildByName("time") as Laya.Image
const label_time = HBox.getChildByName("label_time") as Laya.Text
const duration = doStage.get_duration()
const timeStr = Utility_ConvertSecondToString(duration)
label_time.text = `${timeStr} - ${doStage.get_difficulty()}`
label_time.width = label_time.textWidth
HBox.width = time.width + HBox.space + label_time.textWidth
}
} else {
console.log("当前主线关卡未开始")