按钮文本对齐

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

View File

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