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
Behavior
:
public
Component
{
19
friend
class
GameObject
;
20
public
:
21
Behavior
() =
default
;
22
~Behavior
()
override
=
default
;
23
24
// --- 生命周期 ---
25
void
onCreate
()
override
;
26
void
onAttach
()
override
;
27
virtual
void
onStart
();
28
virtual
void
onUpdate
();
29
void
onDetach
()
override
;
30
void
onDestroy
()
override
;
31
32
bool
isStarted
()
const
{
return
m_isStarted
; }
33
void
setStarted
(
bool
isStarted
) {
m_isStarted
=
isStarted
; }
34
35
protected
:
36
bool
m_isStarted
=
false
;
37
};
38
}
Component.h
SHIT_API
#define SHIT_API
定义
Core.h:12
Shit::Behavior::GameObject
friend class GameObject
定义
Behavior.h:19
Shit::Behavior::m_isStarted
bool m_isStarted
定义
Behavior.h:36
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:33
Shit::Behavior::isStarted
bool isStarted() const
onStart 是否已执行过
定义
Behavior.h:32
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:22
Shit
定义
AudioPlayer.h:9
ShitEngine
Component
Behavior.h
制作者
1.17.0