ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
Behavior.h
浏览该文件的文档.
1
#pragma once
2
#include "
Component.h
"
3
4
namespace
Shit
{
5
class
GameObject
;
6
18
class
SHIT_API
SHIT_REFLECT
(BlackList)
Behavior
:
public
Component
{
19
friend
class
GameObject
;
20
SHIT_REFLECT_BODY
(
Behavior
)
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
; }
34
void
setStarted
(
bool
isStarted
) {
m_isStarted
=
isStarted
; }
35
36
protected
:
37
SHIT_META
(({.displayName =
"Started"
, .tooltip =
"onStart 是否已执行过"
, .readOnly =
true
}))
38
bool
m_isStarted
=
false
;
39
};
40
}
Component.h
SHIT_API
#define SHIT_API
定义
Core.h:14
SHIT_REFLECT_BODY
#define SHIT_REFLECT_BODY(Type)
定义
Macros.h:62
SHIT_REFLECT
#define SHIT_REFLECT(Mode)
定义
Macros.h:59
SHIT_META
#define SHIT_META(...)
定义
Macros.h:68
Shit::Behavior::GameObject
friend class GameObject
定义
Behavior.h:19
Shit::Behavior::m_isStarted
bool m_isStarted
定义
Behavior.h:38
Shit::Behavior::Behavior
Behavior()=default
Shit::Behavior::~Behavior
~Behavior() override=default
Shit::Behavior::onStart
virtual void onStart()
首次 update 前执行一次
Shit::Behavior::setStarted
void setStarted(bool isStarted)
定义
Behavior.h:34
Shit::Behavior::isStarted
bool isStarted() const
onStart 是否已执行过
定义
Behavior.h:33
Shit::Behavior::onUpdate
virtual void onUpdate()
每帧执行
Shit::Behavior::onCreate
void onCreate() override
Shit::Behavior::onAttach
void onAttach() override
Shit::Behavior::onDetach
void onDetach() override
Shit::Behavior::onDestroy
void onDestroy() override
Shit::Component::Component
Component()
Shit::GameObject
游戏物体类
定义
GameObject.h:23
Shit
定义
AudioPlayer.h:10
include
ShitEngine
Component
Behavior.h
制作者
1.17.0