![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <node.hpp>
Public Member Functions | |
| Node (const std::string &name="Node") | |
| virtual | ~Node () |
| void | free () |
| Node * | getOwner () |
| std::shared_ptr< Window > | getWindow () |
| void | setWindow (std::shared_ptr< Window > window) |
| void | addChild (std::shared_ptr< Node > child) |
| void | removeChild (std::shared_ptr< Node > child) |
| std::shared_ptr< Node > | getChild (std::string name) |
| std::shared_ptr< Node > | getChildByIndex (int index) |
| void | addComponent (std::shared_ptr< Component > component) |
| void | removeComponent (std::shared_ptr< Component > component) |
| template<typename T > | |
| std::shared_ptr< T > | getComponent () |
| std::shared_ptr< Component > | getComponentByIndex (int index) |
| virtual void | render (Graphics &graphics, Engine *engine, std::shared_ptr< Window > window) const |
| virtual void | update (float deltaTime) |
| virtual void | physicsUpdate () const |
| virtual void | initialize () |
| virtual void | postLoad () |
| virtual void | input (InputEvent &event) |
| virtual void | exit () const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Attributes | |
| std::string | name |
| Transform | transform |
| Transform | globalTransform |
| Node * | parent |
| std::vector< std::shared_ptr< Node > > | children |
| std::vector< std::shared_ptr< Component > > | components |
Everything in Calamity Engine is composed of nodes. An analogy would be that a node is like a GameObject in Unity. It can have components, children, and a transform. It also has a name for easy identification and lookup. The node class is responsible for updating and rendering itself and its children, as well as managing its components.
It has methods available for adding and removing children and components, as well as getting them by name/index. Here is an example of a node with a sprite component and a script component:
| Node::Node | ( | const std::string & | name = "Node" | ) |
|
virtual |
| void Node::addChild | ( | std::shared_ptr< Node > | child | ) |
| void Node::addComponent | ( | std::shared_ptr< Component > | component | ) |
|
virtual |
| void Node::free | ( | ) |
| std::shared_ptr< Node > Node::getChild | ( | std::string | name | ) |
| std::shared_ptr< Node > Node::getChildByIndex | ( | int | index | ) |
| std::shared_ptr< Component > Node::getComponentByIndex | ( | int | index | ) |
| Node * Node::getOwner | ( | ) |
| std::shared_ptr< Window > Node::getWindow | ( | ) |
|
virtual |
|
virtual |
|
inline |
|
virtual |
|
virtual |
| void Node::removeChild | ( | std::shared_ptr< Node > | child | ) |
| void Node::removeComponent | ( | std::shared_ptr< Component > | component | ) |
|
virtual |
|
inline |
| void Node::setWindow | ( | std::shared_ptr< Window > | window | ) |
|
virtual |
| std::vector<std::shared_ptr<Node> > Node::children |
| std::vector<std::shared_ptr<Component> > Node::components |
| Transform Node::globalTransform |
| std::string Node::name |
| Node* Node::parent |
| Transform Node::transform |