ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
TransformComponent.h
浏览该文件的文档.
1#pragma once
2#include "Component.h"
3#include "../Math.h"
4
5namespace Shit {
6 class GameObject;
7
12 friend class GameObject;
14 public:
16 ~TransformComponent() override = default;
17
18 // --- getter & setter ---
19 const Vector2& getPosition() const { return m_position; }
20 void setPosition(const Vector2& position) { m_position = position; }
21
22 const Vector2& getScale() const { return m_scale; }
23 void setScale(const Vector2& scale) { m_scale = scale; }
24
25 float getRotation() const { return m_rotation; }
26 void setRotation(float rotation) { m_rotation = rotation; }
27
28 private:
29 SHIT_META(({.displayName = "Position"}))
30 Vector2 m_position{ 0.0f, 0.0f };
31 SHIT_META(({.displayName = "Scale", .range = {0, 10}, .step = 0.1}))
32 Vector2 m_scale{ 1.0f, 1.0f };
33 SHIT_META(({.displayName = "Rotation", .range = {-360, 360}}))
34 float m_rotation = 0.0f;
35 };
36}
#define SHIT_API
定义 Core.h:14
#define SHIT_REFLECT_BODY(Type)
定义 Macros.h:62
#define SHIT_REFLECT(Mode)
定义 Macros.h:59
#define SHIT_META(...)
定义 Macros.h:68
游戏物体类
定义 GameObject.h:23
friend class GameObject
定义 TransformComponent.h:12
float getRotation() const
定义 TransformComponent.h:25
void setRotation(float rotation)
定义 TransformComponent.h:26
const Vector2 & getPosition() const
定义 TransformComponent.h:19
const Vector2 & getScale() const
定义 TransformComponent.h:22
void setPosition(const Vector2 &position)
定义 TransformComponent.h:20
void setScale(const Vector2 &scale)
定义 TransformComponent.h:23
~TransformComponent() override=default
定义 AudioPlayer.h:10
glm::vec2 Vector2
定义 Math.h:5