Center floaty text
This commit is contained in:
@@ -27,6 +27,10 @@ void damageEvent(ecs_entity_t entity, DamageEvent event) {
|
|||||||
.elapsed = 0
|
.elapsed = 0
|
||||||
};
|
};
|
||||||
snprintf(floatyText.text, sizeof(floatyText.text), "-%.1f", event.amount);
|
snprintf(floatyText.text, sizeof(floatyText.text), "-%.1f", event.amount);
|
||||||
|
const Game *game = ecs_singleton_get(ECS, Game);
|
||||||
|
Vector2 textSize = MeasureTextEx(game->font, floatyText.text, floatyText.txtSize, 1.0f);
|
||||||
|
floatyText.pos.x -= textSize.x * 0.5f;
|
||||||
|
floatyText.pos.y -= textSize.y * 0.5f;
|
||||||
ecs_entity_t floaty = entityCreateEmpty();
|
ecs_entity_t floaty = entityCreateEmpty();
|
||||||
ecs_set_ptr(ECS, floaty, FloatyTextParticle, &floatyText);
|
ecs_set_ptr(ECS, floaty, FloatyTextParticle, &floatyText);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user