A class representing a game object.
More...
#include <GameObject.hpp>
|
|
std::shared_ptr< Core::Drawable > | m_Drawable = nullptr |
| |
|
std::vector< std::shared_ptr< GameObject > > | m_Children |
| |
|
float | m_ZIndex = 0 |
| |
|
bool | m_Visible = true |
| |
|
glm::vec2 | m_Pivot = {0, 0} |
| |
A class representing a game object.
This class encapsulates the properties and behaviors of a game object.
- Note
- This is an abstract class. Inherit from this class to create your own game objects.
◆ GameObject() [1/2]
| Util::GameObject::GameObject |
( |
const std::shared_ptr< Core::Drawable > & |
drawable, |
|
|
const float |
zIndex, |
|
|
const glm::vec2 & |
pivot = {0, 0}, |
|
|
const bool |
visible = true, |
|
|
const std::vector< std::shared_ptr< GameObject > > & |
children = std::vector<std::shared_ptr<GameObject>>() |
|
) |
| |
|
inline |
Parameterized constructor.
- Parameters
-
| drawable | The Util::Drawable component of the game object. |
| zIndex | The z-index of the game object. |
| visible | The visibility of the game object. |
| children | The children of the game object. |
◆ GameObject() [2/2]
| Util::GameObject::GameObject |
( |
const GameObject & |
other | ) |
|
|
default |
Copy constructor.
- Parameters
-
- Note
- This is a shallow copy constructor, meaning the m_Drawable points to the same reference as same as
other's does.
◆ AddChild()
| void Util::GameObject::AddChild |
( |
const std::shared_ptr< GameObject > & |
child | ) |
|
|
inline |
Add a child to the game object.
- Parameters
-
| child | The new child of the game object. |
◆ GetChildren()
| const std::vector< std::shared_ptr< GameObject > > & Util::GameObject::GetChildren |
( |
| ) |
const |
|
inline |
Get the children of the game object.
- Returns
- The children of the game object.
◆ GetScaledSize()
| glm::vec2 Util::GameObject::GetScaledSize |
( |
| ) |
const |
|
inline |
Get the size of its drawable component.
- Returns
- vec2(x, y) representing the size of the drawable component.
◆ GetTransform()
| Transform Util::GameObject::GetTransform |
( |
| ) |
const |
|
inline |
Get the transform of the game object.
- Returns
- The transform of the game object.
◆ GetZIndex()
| float Util::GameObject::GetZIndex |
( |
| ) |
const |
|
inline |
Get the z-index of the game object.
- Returns
- The z-index of the game object.
◆ RemoveChild()
| void Util::GameObject::RemoveChild |
( |
const std::shared_ptr< GameObject > & |
child | ) |
|
|
inline |
Remove a child from the game object.
- Parameters
-
| child | The child to be removed. |
◆ SetDrawable()
| void Util::GameObject::SetDrawable |
( |
const std::shared_ptr< Core::Drawable > & |
drawable | ) |
|
|
inline |
Set the drawable component of the game object.
- Parameters
-
| drawable | The new drawable component of the game object. |
◆ SetPivot()
| void Util::GameObject::SetPivot |
( |
const glm::vec2 & |
pivot | ) |
|
|
inline |
Set the pivot of the game object.
- Parameters
-
| pivot | The pivot of the game object. |
◆ SetVisible()
| void Util::GameObject::SetVisible |
( |
const bool |
visible | ) |
|
|
inline |
Set the visibility of the game object.
- Parameters
-
| visible | The new visibility of the game object. |
◆ SetZIndex()
| void Util::GameObject::SetZIndex |
( |
float |
index | ) |
|
|
inline |
Set the z-index of the game object. z-index is used to determine the order in which game objects are drawn, the greater z-index, the topper the its Util::Drawable is.
- Parameters
-
| index | The new z-index of the game object. |
The documentation for this class was generated from the following file: