SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::core::Component Class Reference

A component that can be attached to a GameObject to provide additional functionality. More...

#include <Component.h>

Inheritance diagram for spark::core::Component:
spark::rtti::HasRtti spark::core::components::Circle spark::core::components::Collider spark::core::components::Image spark::core::components::Rectangle spark::core::components::Text spark::core::components::Transform spark::core::components::DynamicCollider spark::core::components::StaticCollider

Public Member Functions

 Component (GameObject *parent)
 Instantiates a new Component.
 
 Component (const Component &other)=delete
 
 Component (Component &&other) noexcept=default
 
Componentoperator= (const Component &other)=delete
 
Componentoperator= (Component &&other) noexcept=default
 
const lib::Uuiduuid () const
 Gets the UUID of the component.
 
GameObjectgameObject ()
 Gets the GameObject that the component is attached to.
 
const GameObjectgameObject () const
 Gets the GameObject that the component is attached to.
 
virtual void render () const
 Renders the component.
 
virtual void onAttach ()
 Method called when the component is attached to a GameObject.
 
virtual void onUpdate (float dt)
 Method called on every frame.
 
virtual void onDetach ()
 Method called when the component is detached from a GameObject.
 
- Public Member Functions inherited from spark::rtti::HasRtti
 HasRtti (const HasRtti &other)=default
 
 HasRtti (HasRtti &&other) noexcept=default
 
HasRttioperator= (const HasRtti &other)=default
 
HasRttioperator= (HasRtti &&other) noexcept=default
 
virtual RttiBaserttiInstance () const =0
 

Detailed Description

A component that can be attached to a GameObject to provide additional functionality.

This class is the base for all components. It should not be used directly but rather inherited from to create a new component.

Constructor & Destructor Documentation

◆ Component()

spark::core::Component::Component ( GameObject * parent)
explicit

Instantiates a new Component.

Parameters
parentThe GameObject that the component will be attached to.

Member Function Documentation

◆ gameObject() [1/2]

GameObject * spark::core::Component::gameObject ( )
nodiscard

Gets the GameObject that the component is attached to.

Returns
A pointer to the GameObject that the component is attached to.

◆ gameObject() [2/2]

const GameObject * spark::core::Component::gameObject ( ) const
nodiscard

Gets the GameObject that the component is attached to.

Returns
A const pointer to the GameObject that the component is attached to.

◆ onUpdate()

virtual void spark::core::Component::onUpdate ( float dt)
inlinevirtual

Method called on every frame.

Parameters
dtThe time in seconds since the last frame.

Reimplemented in spark::core::components::DynamicCollider.

◆ render()

virtual void spark::core::Component::render ( ) const
inlinevirtual

◆ uuid()

const lib::Uuid & spark::core::Component::uuid ( ) const
nodiscard

Gets the UUID of the component.

Returns
A const reference to the UUID of the component.