R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::Transform Class Reference

Component representing position, rotation and scale in 2D space. More...

#include <Transform.hpp>

Inheritance diagram for ecs::Transform:
Inheritance graph
Collaboration diagram for ecs::Transform:
Collaboration graph

Classes

struct  Vector2
 2D vector structure for positions and scales. More...
 

Public Member Functions

 Transform ()
 Default constructor. Initializes position to (0, 0), rotation to 0, and scale to (1, 1).
 
 Transform (float posX, float posY)
 Constructor with position only.
 
 Transform (float posX, float posY, float rotation, float scaleX, float scaleY)
 Full constructor with all parameters.
 
 ~Transform () override=default
 
Vector2 getPosition () const
 Get the position vector.
 
float getRotation () const
 Get the rotation angle.
 
Vector2 getScale () const
 Get the scale vector.
 
void setPosition (float posX, float posY)
 Set the position.
 
void setRotation (float rotation)
 Set the rotation angle.
 
void setScale (float scaleX, float scaleY)
 Set the scale factors.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

Vector2 _position
 Entity position in world space.
 
float _rotation
 Rotation angle in degrees.
 
Vector2 _scale
 Scale factors (default: 1, 1)
 

Detailed Description

Component representing position, rotation and scale in 2D space.

This component stores the spatial transformation data for an entity. It includes position (x, y), rotation angle, and scale factors.

Definition at line 20 of file Transform.hpp.

Constructor & Destructor Documentation

◆ Transform() [1/3]

ecs::Transform::Transform ( )
inline

Default constructor. Initializes position to (0, 0), rotation to 0, and scale to (1, 1).

Definition at line 35 of file Transform.hpp.

◆ Transform() [2/3]

ecs::Transform::Transform ( float  posX,
float  posY 
)
inline

Constructor with position only.

Parameters
posXX position
posYY position

Definition at line 42 of file Transform.hpp.

◆ Transform() [3/3]

ecs::Transform::Transform ( float  posX,
float  posY,
float  rotation,
float  scaleX,
float  scaleY 
)
inline

Full constructor with all parameters.

Parameters
posXX position
posYY position
rotationRotation angle in degrees
scaleXX scale factor
scaleYY scale factor

Definition at line 52 of file Transform.hpp.

◆ ~Transform()

ecs::Transform::~Transform ( )
overridedefault

Member Function Documentation

◆ getPosition()

◆ getRotation()

float ecs::Transform::getRotation ( ) const
inline

Get the rotation angle.

Returns
float The rotation in degrees.

Definition at line 67 of file Transform.hpp.

References _rotation.

Referenced by scripting::bindings::bindComponents().

◆ getScale()

Vector2 ecs::Transform::getScale ( ) const
inline

Get the scale vector.

Returns
Vector2 The current scale factors.

Definition at line 73 of file Transform.hpp.

References _scale.

◆ getType()

ComponentType ecs::Transform::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for Transform component.

Implements ecs::IComponent.

Definition at line 105 of file Transform.hpp.

◆ setPosition()

void ecs::Transform::setPosition ( float  posX,
float  posY 
)
inline

Set the position.

Parameters
posXNew X position
posYNew Y position

Definition at line 80 of file Transform.hpp.

References _position, ecs::Transform::Vector2::x, and ecs::Transform::Vector2::y.

Referenced by scripting::bindings::bindComponents(), ecs::WeaponSystem::fireMultipleShots(), and ecs::OrbitalSystem::updateOrbitalPosition().

◆ setRotation()

void ecs::Transform::setRotation ( float  rotation)
inline

Set the rotation angle.

Parameters
rotationNew rotation in degrees

Definition at line 89 of file Transform.hpp.

References _rotation.

Referenced by scripting::bindings::bindComponents().

◆ setScale()

void ecs::Transform::setScale ( float  scaleX,
float  scaleY 
)
inline

Set the scale factors.

Parameters
scaleXNew X scale factor
scaleYNew Y scale factor

Definition at line 96 of file Transform.hpp.

References _scale, ecs::Transform::Vector2::x, and ecs::Transform::Vector2::y.

Member Data Documentation

◆ _position

Vector2 ecs::Transform::_position
private

Entity position in world space.

Definition at line 108 of file Transform.hpp.

Referenced by getPosition(), and setPosition().

◆ _rotation

float ecs::Transform::_rotation
private

Rotation angle in degrees.

Definition at line 109 of file Transform.hpp.

Referenced by getRotation(), and setRotation().

◆ _scale

Vector2 ecs::Transform::_scale
private

Scale factors (default: 1, 1)

Definition at line 110 of file Transform.hpp.

Referenced by getScale(), and setScale().


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