Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Engine::Node Class Reference

A single node in a game scene. More...

#include <Node.hpp>

Inheritance diagram for Engine::Node:
Engine::GameObject Engine::UI::UIElement Engine::Camera Engine::UI::UIInput Engine::UI::UILabel Engine::UI::UIButton

Public Member Functions

 Node (std::string name)
 Default constructor.
 
virtual ~Node ()
 Default destructor.
 
size_t AddChild (Node *child)
 Adds a child to the node and assigns itself as the parent of the new node.
 
NodeGetChild (size_t index)
 Returns a reference to the child at the specified index.
 
Success RemoveChild (size_t index)
 Removes the child at the specified index.
 
Success SetEnabled (bool enabled=true)
 Toggles the state of the node.
 
virtual void OnEnable ()
 Overridable enable method for the node.
 
virtual void OnDisable ()
 Overridable disable method for the node.
 
virtual void Init ()
 
virtual void Draw ()
 Overridable draw method for the node.
 
virtual void Update (float dt)
 Overridable update method for the node.
 

Public Attributes

const char * m_nodeType
 
std::string m_name
 

Protected Attributes

Nodem_parent
 

Detailed Description

A single node in a game scene.

Each node is linked with a parent and its children. Nodes can be game objects, scenes, UI elements, etc. There are predefined subclasses, but you can also make your own to manage the behaviour of scenes.

Example

class ExampleNode : public Node {
public:
Cube mesh;
CubeObject() : Node("Cube") {}
}
class ExampleScene : public Scene {
public:
ExampleNode node;
ExampleScene() : Scene("ExampleScene") {
AddChild(&node);
}
}
A single node in a game scene.
Definition Node.hpp:43
Author
Roberto Selles

Member Function Documentation

◆ AddChild()

size_t Engine::Node::AddChild ( Node child)

Adds a child to the node and assigns itself as the parent of the new node.

Parameters
childThe child to add
Returns
The index of the child

◆ Draw()

void Engine::Node::Draw ( )
virtual

Overridable draw method for the node.

Warning
To maintain recursiveness, this method must be called in each method override

◆ GetChild()

Engine::Node * Engine::Node::GetChild ( size_t  index)

Returns a reference to the child at the specified index.

Parameters
indexThe index of the child to return
Returns
A reference to the child

◆ Init()

void Engine::Node::Init ( )
virtual

◆ OnDisable()

void Engine::Node::OnDisable ( )
virtual

Overridable disable method for the node.

Calls this whenever the node is disabled

Reimplemented in Engine::UI::UIElement.

◆ OnEnable()

void Engine::Node::OnEnable ( )
virtual

Overridable enable method for the node.

Calls this whenever the node is enabled

Reimplemented in Engine::UI::UIElement.

◆ RemoveChild()

Engine::Success Engine::Node::RemoveChild ( size_t  index)

Removes the child at the specified index.

Parameters
indexThe index of the child to remove
Returns
SUCCESS if the child was removed, FAILURE otherwise

◆ SetEnabled()

Engine::Success Engine::Node::SetEnabled ( bool  enabled = true)

Toggles the state of the node.

This method triggers callbacks onEnable and onDisable if the state changes successfully.

Parameters
enabledThe new state of the node
Returns
SUCCESS if the state changed successfully, FAILURE otherwise

◆ Update()

void Engine::Node::Update ( float  dt)
virtual

Overridable update method for the node.

Warning
To maintain recursiveness, this method must be called in each method override

The documentation for this class was generated from the following files: