jade-engine
0.0
|
#include <IGameObject.h>
Public Member Functions | |
IGameObject () | |
virtual void | Update () |
virtual void | Clean () |
virtual LoadState | Load (SDL_Renderer *renderer) |
virtual void | Render (SDL_Renderer *renderer) |
LoadState | GetLoadState () const |
void | SetLoadState (const LoadState newState) |
bool | IsShown () const |
virtual void | Show (const bool show) |
int32_t | GetZ () const |
void | Destroy () |
bool | DestructionWanted () const |
Public Attributes | |
const std::shared_ptr< Transform > | transform |
Protected Attributes | |
LoadState | _loadState |
bool | _shown |
int32_t | _z |
Interface for game objects.
The most basic building block of Jade Engine, game objects are objects that live inside a scene and can be updated and rendered every frame.
Additionally game objects can be used to compose simple game objects into more advanced ones. For example a Button game object will have collection of Sprite game objects for various pressed states and a Text game objects.
When creating new game objects based on IGameObject it is necessary to create a constructor that accepts only one argument: constant reference to creation structure which will contain at the very least ObjectLayer layer;
member. See following example:
|
inline |
Default constructor for game object.
|
inlinevirtual |
Triggered when the game object is about to be destroyed or reset.
All resources belonging solely to the game object, such as textures, should be released at this point. The game object instance itself may or may not be destroyed after this callback.
Reimplemented in JadeEngine::Sprite, JadeEngine::Text, and JadeEngine::TextBox.
|
inline |
Mark the object to be destroyed.
At the begging of the next frame its Clean function will be called and the game object will removed from list of game objects.
|
inline |
Returns whether the object is marked for destruction.
|
inline |
Return the current load state of the game object.
|
inline |
Returns Z coordinate. The game objects with higher Z coordinate will be drawn over the ones with lower one.
|
inline |
Returns whether game object is currently shown.
Only shown objects are rendered and have their Render function triggered.
|
inlinevirtual |
Triggered every frame when GetLoadState function returns kLoadState_Wanted
to allow resources, such as textures, to be loaded.
The trigger order is the following: IScene::PreUpdate -> IGameObject::Load -> IGameObject::Update -> IScene::Update -> IGameObject::Load -> IGameObject::Render.
renderer | The engine's SDL2 renderer that can be used to create resources. |
Reimplemented in JadeEngine::TextSprite, JadeEngine::TextBox, and JadeEngine::Text.
|
inlinevirtual |
Triggered every frame while the scene that owns this game object is active, the game object was successfully loaded and the game object is shown.
The trigger order is the following: IScene::PreUpdate -> IGameObject::Load -> IGameObject::Update -> IScene::Update -> IGameObject::Load -> IGameObject::Render.
renderer | The engine's SDL2 renderer that should be used to render the game object. |
Reimplemented in JadeEngine::Sprite, JadeEngine::LineStrip, JadeEngine::TextSprite, JadeEngine::TextBox, JadeEngine::Text, and JadeEngine::BoxSprite.
|
inline |
Set the load state to a new value.
|
inlinevirtual |
Show or hide game object.
Reimplemented in JadeEngine::Button, JadeEngine::Dropdown, JadeEngine::ProgressBar, JadeEngine::Slider, JadeEngine::Tooltip, JadeEngine::LineGrid, JadeEngine::Checkbox, JadeEngine::LineBox, and JadeEngine::FTC.
|
inlinevirtual |
Triggered every frame while the scene that owns this game object is active and the game object was successfully loaded.
The trigger order is the following: IScene::PreUpdate -> IGameObject::Load -> IGameObject::Update -> IScene::Update -> IGameObject::Load -> IGameObject::Render.
To obtain delta time since last frame use GTime.deltaTime.
Reimplemented in JadeEngine::Button, JadeEngine::LineStrip, JadeEngine::ProgressBar, JadeEngine::Dropdown, JadeEngine::Slider, JadeEngine::Tooltip, JadeEngine::LineGrid, JadeEngine::Checkbox, and JadeEngine::LineBox.
const std::shared_ptr<Transform> JadeEngine::IGameObject::transform |