ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
Behavior.h
浏览该文件的文档.
1#pragma once
2#include "Component.h"
3
4namespace Shit {
5 class GameObject;
6
18 class SHIT_API SHIT_REFLECT(BlackList) Behavior : public Component {
19 friend class GameObject;
21 public:
22 Behavior() = default;
23 ~Behavior() override = default;
24
25 // --- 生命周期 ---
26 void onCreate() override;
27 void onAttach() override;
28 virtual void onStart();
29 virtual void onUpdate();
30 void onDetach() override;
31 void onDestroy() override;
32
33 bool isStarted() const { return m_isStarted; }
35
36 protected:
37 SHIT_META(({.displayName = "Started", .tooltip = "onStart 是否已执行过", .readOnly = true}))
38 bool m_isStarted = false;
39 };
40}
#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
friend class GameObject
定义 Behavior.h:19
bool m_isStarted
定义 Behavior.h:38
Behavior()=default
~Behavior() override=default
virtual void onStart()
首次 update 前执行一次
void setStarted(bool isStarted)
定义 Behavior.h:34
bool isStarted() const
onStart 是否已执行过
定义 Behavior.h:33
virtual void onUpdate()
每帧执行
void onCreate() override
void onAttach() override
void onDetach() override
void onDestroy() override
游戏物体类
定义 GameObject.h:23
定义 AudioPlayer.h:10