Its base class for all game objects, eg. Player, Enemy, Weapon. Your Class needs to inherit from it. More...
#include <GameObject.hpp>
Public Member Functions | |
| GameObject (Engine &engine, const std::string &name) | |
| Default constructor for GameObject. | |
| void | Destroy () |
| Destroys the GameObject and removes it from the engine's registry. | |
| virtual | ~GameObject () |
| Destructor. | |
| GameObject (const GameObject &)=delete | |
| GameObject & | operator= (const GameObject &)=delete |
| GameObject (GameObject &&other) noexcept | |
| virtual void | BeginPlay () |
| virtual void function you override to implement custom behavior when the game starts. | |
| virtual void | Update (float deltaTime) |
| virtual void function you override to implement custom behavior when the game updates (eg. every frame). | |
| vex::Entity | GetEntity () const |
| Function that returns entity object, which is the entity associated with this GameObject. Its mostly needed for parenting and other engine internal usage. | |
| Engine & | GetEngine () |
| Function that returns engine reference allowing your custom Object to use engine provided methods. | |
| template<typename T> | |
| T & | GetComponent () |
| Function that returns reference to a requested component. | |
| template<typename T> | |
| void | AddComponent (const T &comp) |
| Function that adds a component to the GameObject. | |
| template<typename T> | |
| bool | HasComponent () const |
| Function that checks if the GameObject has a component. | |
| bool | isValid () const |
| void | ParentTo (vex::Entity entity) |
| Function that parent this Object to another GameObject. You need to pass another GameObject's entity. | |
| void | setObjectType (const std::string &type) |
| Function that sets the type of the GameObject. | |
| const std::string & | getObjectType () const |
| Function that returns the type of the GameObject. | |
Protected Attributes | |
| Engine & | m_engine |
| vex::Entity | m_entity |
| bool | m_isValid |
| std::string | objectType |
Its base class for all game objects, eg. Player, Enemy, Weapon. Your Class needs to inherit from it.
Example:
This class serves as the foundation for all game objects within the engine. It provides essential functionalities such as entity management, name registration, and basic component initialization.
Definition at line 31 of file GameObject.hpp.
| vex::GameObject::GameObject | ( | Engine & | engine, |
| const std::string & | name ) |
Default constructor for GameObject.
| Engine& | engine - Reference to the engine instance. |
| const | std::string& name - Unique name for the game object. |
Definition at line 10 of file GameObject.cpp.
|
virtual |
|
inlinenoexcept |
Definition at line 57 of file GameObject.hpp.
|
inline |
Function that adds a component to the GameObject.
Definition at line 80 of file GameObject.hpp.
|
inlinevirtual |
virtual void function you override to implement custom behavior when the game starts.
Reimplemented in vex::BasicCamera.
Definition at line 64 of file GameObject.hpp.
| void vex::GameObject::Destroy | ( | ) |
Destroys the GameObject and removes it from the engine's registry.
Definition at line 20 of file GameObject.cpp.
|
inline |
Function that returns reference to a requested component.
Definition at line 78 of file GameObject.hpp.
|
inline |
Function that returns engine reference allowing your custom Object to use engine provided methods.
Example usage:
You could technically just use m_engine but its highly discarded as it can lead to confusion and potential bugs.
Definition at line 75 of file GameObject.hpp.
|
inline |
Function that returns entity object, which is the entity associated with this GameObject. Its mostly needed for parenting and other engine internal usage.
Definition at line 68 of file GameObject.hpp.
|
inline |
Function that returns the type of the GameObject.
Definition at line 106 of file GameObject.hpp.
|
inline |
Function that checks if the GameObject has a component.
Definition at line 83 of file GameObject.hpp.
|
inline |
Definition at line 84 of file GameObject.hpp.
|
inline |
Function that parent this Object to another GameObject. You need to pass another GameObject's entity.
| vex::Entity | entity - Entity of GameObject we want to parent to. |
Helper function that retrieves the TransformComponent of this object and calls setParent with the provided entity ID.
Definition at line 94 of file GameObject.hpp.
|
inline |
Function that sets the type of the GameObject.
| type | - Type of the GameObject. |
Definition at line 100 of file GameObject.hpp.
|
inlinevirtual |
virtual void function you override to implement custom behavior when the game updates (eg. every frame).
Reimplemented in EditorCameraObject, and vex::BasicCamera.
Definition at line 66 of file GameObject.hpp.
|
protected |
Definition at line 109 of file GameObject.hpp.
|
protected |
Definition at line 110 of file GameObject.hpp.
|
protected |
Definition at line 111 of file GameObject.hpp.
|
protected |
Definition at line 112 of file GameObject.hpp.