Add velocity HUD display (Velocity: 0) in top-left corner
This commit is contained in:
parent
a1d54b01b0
commit
aa9590e2f4
@ -163,6 +163,18 @@
|
||||
"hover": "resources/shoot_hover.png",
|
||||
"pressed": "resources/shoot_pressed.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "TextView",
|
||||
"name": "velocityText",
|
||||
"x": 10,
|
||||
"y": 10,
|
||||
"width": 200,
|
||||
"height": 40,
|
||||
"text": "Velocity: 0",
|
||||
"fontSize": 24,
|
||||
"color": [1.0, 1.0, 1.0, 1.0],
|
||||
"centered": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -1216,8 +1216,13 @@ namespace ZL
|
||||
}
|
||||
|
||||
// update velocity text
|
||||
if (shipAlive && !gameOver) {
|
||||
auto velocityTv = uiManager.findTextView("velocityText");
|
||||
if (velocityTv) {
|
||||
std::string velocityStr = "Velocity: " + std::to_string(static_cast<int>(Environment::shipState.velocity));
|
||||
uiManager.setText("velocityText", velocityStr);
|
||||
}
|
||||
}
|
||||
|
||||
uiManager.update(static_cast<float>(delta));
|
||||
lastTickCount = newTickCount;
|
||||
|
||||
@ -903,7 +903,6 @@ namespace ZL {
|
||||
bool UiManager::setText(const std::string& name, const std::string& newText) {
|
||||
auto tv = findTextView(name);
|
||||
if (!tv) {
|
||||
std::cerr << "TextView not found: " << name << std::endl;
|
||||
return false;
|
||||
}
|
||||
tv->text = newText;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user