【发布时间】:2021-05-15 12:58:08
【问题描述】:
大家好,我正在尝试在窗口的左上角写分数,但由于某种原因它不起作用。这是我用来生成文本的代码:
commands
.spawn(TextBundle{
text: Text{value: "Score:".to_string(),
font: assets.load("FiraSans-Bold.ttf"),
style:TextStyle{
font_size:30.0,
color:Color::WHITE,
..Default::default()},..Default::default()},
transform: Transform::from_translation(Vec3::new(-380.0,-380.0,2.0)),
..Default::default()
})
.with(TextTag);
窗口为 800 x 800。感谢任何帮助。
【问题讨论】:
-
你看过UI example in the bevy repo吗?看起来样式中有一个位置变量,您可以使用它来定位 UI 元素,而不是使用变换。看起来您还需要一个 UI 摄像头,根据您拥有的代码,您可能没有