nightshade 0.8.0

A cross-platform data-oriented game engine.
Documentation
use crate::ecs::world::{Entity, World};
use nalgebra_glm::Vec2;

pub fn spawn_sprite_text(world: &mut World, text: &str, position: Vec2, font_size: f32) -> Entity {
    let entities = world.spawn_entities(crate::ecs::SPRITE_TEXT | crate::ecs::VISIBILITY, 1);
    let entity = entities[0];

    if let Some(sprite_text) = world.get_sprite_text_mut(entity) {
        sprite_text.text = text.to_string();
        sprite_text.position = position;
        sprite_text.font_size = font_size;
        sprite_text.dirty = true;
    }

    if let Some(visibility) = world.get_visibility_mut(entity) {
        visibility.visible = true;
    }

    entity
}