SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Text.h
1#pragma once
2
3#include "spark/core/Component.h"
4
5#include "spark/math/Vector2.h"
6#include "spark/rtti/HasRtti.h"
7
8namespace spark::core::components
9{
10 class Text final : public Component
11 {
12 DECLARE_SPARK_RTTI(Text, Component)
13 SPARK_ALLOW_PRIVATE_SERIALIZATION
14
15 public:
16 explicit Text(GameObject* parent)
17 : Component(parent) {}
18
19 explicit Text(GameObject* parent, std::string content, const math::Vector2<float> offset, std::filesystem::path font_path = "")
20 : Component(parent), m_content(std::move(content)), m_offset(offset), m_fontPath(std::move(font_path)) {}
21
22 void render() const override
23 {
24 //core::Renderer2D::DrawText(m_content, Transform::LocalToWorld(gameObject()->transform()) + m_offset, 72, m_fontPath);
25 }
26
27 private:
28 std::string m_content;
29 math::Vector2<float> m_offset;
30 std::filesystem::path m_fontPath;
31 };
32}
33
34IMPLEMENT_SPARK_RTTI(spark::core::components::Text)
A component that can be attached to a GameObject to provide additional functionality.
Definition Component.h:20
Component(GameObject *parent)
Instantiates a new Component.
Definition Component.cpp:7
A GameObject is any object in the game. It contains a list of components that provides functionality ...
Definition GameObject.h:26
Definition Text.h:11
void render() const override
Renders the component.
Definition Text.h:22
A vector with two components.
Definition Vector2.h:13