|
cangine
|
Base interface for all components attached to a GameObject. More...
#include <component.hpp>


Public Member Functions | |
| IComponent (GameObject *gameObject=nullptr) | |
| Constructs the component, optionally bound to a game object. | |
| virtual | ~IComponent () |
| GameObject * | getGameObject () const |
| Returns the game object this component is attached to. | |
| virtual void | firstFrame () |
| Called once before the first frame update. | |
| virtual void | frame (double deltaTime) |
| Called every frame to update the component. | |
| virtual void | onMouseEvent (const MouseEvent *e) |
| Called when a mouse event is dispatched to the owning object. | |
Public Attributes | |
| bool | isUnique = true |
| If true, only one of this component type may exist per object. | |
Private Attributes | |
| GameObject * | gameObject |
| Owning game object. | |
Friends | |
| class | GameObject |
Base interface for all components attached to a GameObject.
Components implement behavior via lifecycle hooks: firstFrame is called once before the first update, frame is called every frame, and onMouseEvent receives mouse input. Derived components override the hooks they need.
| cangine::IComponent::IComponent | ( | GameObject * | gameObject = nullptr | ) |
Constructs the component, optionally bound to a game object.
| gameObject | Owning game object, or nullptr if unset. |
|
virtualdefault |
|
inlinevirtual |
Called once before the first frame update.
Reimplemented in cangine::QuadRendererComponent, cangine::TextRendererComponent, cangine::Transform, cangine::ButtonComponent, cangine::InputFieldComponent, and cangine::PanelComponent.
|
inlinevirtual |
Called every frame to update the component.
| deltaTime | Seconds elapsed since the previous frame. |
Reimplemented in cangine::PanelComponent, cangine::QuadRendererComponent, cangine::TextRendererComponent, and cangine::InputFieldComponent.
| GameObject * cangine::IComponent::getGameObject | ( | ) | const |
Returns the game object this component is attached to.
nullptr.
|
inlinevirtual |
Called when a mouse event is dispatched to the owning object.
| e | The mouse event. |
Reimplemented in cangine::ButtonComponent, and cangine::InputFieldComponent.
|
friend |
|
private |
Owning game object.
| bool cangine::IComponent::isUnique = true |
If true, only one of this component type may exist per object.